Next-auth: About access token and scopes

Created on 29 May 2020  ยท  4Comments  ยท  Source: nextauthjs/next-auth

First of all, congrats ๐Ÿ’ฏ ๐ŸŽŠ ๐Ÿ’š , this is a very cool project!

I've been trying to set-up a Next app that talks to the Github API and I found the beta of this library by far the nicest and simpler to configure โœจ

I did give a try to Next Auth0, but it seems by far too complicated for my use-case ( and got lost trying to configure stuff in the Auth0 dashboard ๐Ÿ˜‚ )

The issue

I managed to get an app working that connects to Github:
https://github.com/lluia/hip-hub

Taking next-auth-example as a base but modifying it to use Typescript:

I also requested more scopes to be able to query the Github API, which is my next step.

Assuming the access token stored in the session is what Github give us back, I'm trying to CURL the API with it as per the docs but I get the following error:

$ curl -H "Authorization: bearer [token]" -X POST -d " \
 { \
   \"query\": \"query { viewer { login }}\" \
 } \
" https://api.github.com/graphql

{
  "message": "Bad credentials",
  "documentation_url": "https://developer.github.com/v4"
}

In theory, it should work ๐Ÿ˜… ๐Ÿคท๐Ÿปโ€โ™‚๏ธ , appreciate any help with this ๐Ÿ™๐Ÿป

Most helpful comment

Thanks, this should do for now ๐Ÿ’ฏ

I think having it in the docs woulb be useful ๐Ÿ™๐Ÿป

All 4 comments

The tokens are stored in the Accounts table. This also has been discussed here.

@iaincollins maybe I can add this to the OAuth section of the providers docs?

Thanks, this should do for now ๐Ÿ’ฏ

I think having it in the docs woulb be useful ๐Ÿ™๐Ÿป

Thanks for sharing @lluia ! I'm glad it's working out and appreciate the feedback and the question.

@LoriKarikari I think your right! Sounds like it's worth us documenting some example code for now as it seems like a common question

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benoror picture benoror  ยท  3Comments

iaincollins picture iaincollins  ยท  3Comments

bscaspar picture bscaspar  ยท  3Comments

alephart picture alephart  ยท  3Comments

iaincollins picture iaincollins  ยท  3Comments