-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server Error: Unauthorized #15
Comments
Any idea of how to solve this? |
Can you verify if the DRUPAL_CLIENT_ID and DRUPAL_CLIENT_SECRET are correct? |
Any errors in the Drupal logs? |
I have setup only 1 user, that is the default one, with the following parameters: And I am using the following data in the env.local file (of the NextJs client app):
I can see the following error log in the Drupal site once I try to run the http://localhost:3000:
I am not super expert of the simple_oauth module, with JSONAPI, but I am wondering that the miss of any generated token could mean something here ... Simple OAuth Settings looks like the followings (and I can see the Generated Keys in my "sites/default/files/private" folder ... |
I am concerned there is something wrong with the Oauth module settings (and still don't get what as I am not now able to xdebug it).
Should something be properly set on the Rest Resources (/admin/config/services/rest) or somewhere else on JSONAPI that is not mentioned in the Quickstart guide??? |
Ah! Finally I was able to make (almost) all this working ... For sake of sharing my findings, after creating a consumer Client Application, it is crucial properly generate the Access Tokens with some POST request of the following type:
I thing reference to all this Oauth module setup (and generation of access tokens) should be mentioned in the Quickstart guide & repo documentation, for all those (like me) are not expert of the Drupal Oauth module. |
Thanks for the update and the fix @itamair. I'll update the documentation. If you have any other suggestions on how we can improve the onboarding/setup process, you can ping me. |
I have the same issue. I used this thread to get a proper response via Postman. However, the issue remains. I feel like the issue with with the keys, but I am not sure how to fix it. I have tried generating the keys in admin/config/people/simple_oauth as well as via CLI as per the instructions in https://www.drupal.org/project/simple_oauth, neither results in a fix for me. I will be watching this thread for updates, thanks. |
I had the same problem on old test installation and it was gone after re-creating credentials on drupal side (ids and secrets but not the certificates) and updating .env.local file in accordance. Fresh installation by guide worked fine (https://next-drupal.org/docs/quick-start). |
Hi all were the docs https://next-drupal.org/docs/quick-start updated or do I need to do extra OAuth2 stuff as mentioned by @itamair ? |
@Juc1 I've not updated the docs yet. Are you facing the same issues? |
@shadcn yes I am getting "Error:Unauthorised" like itamair's screenshot at the top of this issue. |
I noticed this issue when I created a client/consumer before generating keys (private and public) keys. I fixed this by deleting the consumer and recreating it again. |
Had the same issue and I recreated the Consumer, regenerated the keys and it started working for me. FYI @itamair I created a I see your's are in a private folder - perhaps the above method might be better.
|
Had the same issue, tried all of the above solutions : generated token with curl, deleted and recreated consumer... I'm using ddev for Drupal and I could solve it after I filled NEXT_PUBLIC_DRUPAL_BASE_URL and NEXT_IMAGE_DOMAIN values with the http url (eg http://myblog.site:8008) instead of the https one (_https://myblog.ddev.site _). By the way, I stumble then on Not found errors, whether on the homepage or after creating some content. Even If it sounds obvious afterwards, I suggest that you mention in the quick start guide, to enable Json Api module, and any other required dependencies. Thanks for this promising repo and the amazing work done ! |
The Next.js JSON:API module list JSON:API module as a dependency. I'll update the docs. @KojoEnch I've been wanting to try ddev for a while. Are you running both Drupal and the Next.js site on the same setup? Mind sharing your config? Thanks for the feedback. Appreciate the feedback. |
Well, I just use ddev default config. I use ddev most of the time now for a while and recommend it, since it provides a full containerized dev env for each project in less than a minute. So I made a new fresh install following your quick start guide this morning, and I can confirm that for ddev users, the install problem comes from the https. I think node complains for self signed certificates, I've had the same problem in a previous hand made drupal + next config. There are ways to setup that but this is beyond the scope of that issue. So for a clean install with ddev :
Then follow the install from https://next-drupal.org/docs/quick-start#4-create-site until .env.local step and fill in NEXT_PUBLIC_DRUPAL_BASE_URL with ddev http url : No extra needs, the tokens are properly set when we access front site, and front page is accessible without error. |
@KojoEnch Thank you. I'll add this to the documentation. |
I'm starting to test this tool on Drupal 9.3. I'm also using ddev. I too had a It was not necessary for me to use the http url. In other words, |
I'm seeing new tokens being created every time the front end refreshes. Also seeing this error in the Drupal log:
|
@darrenoh this error is a known issue in the Simple OAuth module. See:
Can you create a separate issue to track the token generation issue please? Thank you |
Did you try deleting and recreating the consumer? |
I had the same issue as above. The Drupal error log was:
I also think that the tool from https://github.com/shadcn/next-drupal-debug should be included on the main repository as a tool... |
@itamair I'm going to close this as done/stale. Feel free to reopen if not. Thank you. |
I appreciate that this is closed. However just adding one more scenario that causes this error that I solved using this thread (the My Drupal salt was too short. The error message I received eventually was: {
"error": "server_error",
"error_description": "The authorization server encountered an unexpected condition which prevented it from fulfilling the request: Hash salt must be at least 32 characters long.",
"message": "The authorization server encountered an unexpected condition which prevented it from fulfilling the request: Hash salt must be at least 32 characters long."
} |
As a follow up of this #14 resolution, I now hit this error on http://localhost:3000
The text was updated successfully, but these errors were encountered: