nextjs-auth0: Don't get IdToken nor AccessToken
I’m able to login to Auth0. But whenever I switch on any of the tokens, I don’t get a valid session any more. I never get an IdToken nor an AccessToken into my session for using them with Apollo authenticating in Hasura:
// Store the id_token in the session. Defaults to false.
storeIdToken: true,
// Store the access_token in the session. Defaults to false.
storeAccessToken: true,
"@apollo/react-hooks": "3.1.3",
"@apollo/react-ssr": "3.1.3",
"@auth0/nextjs-auth0": "^0.10.0",
"apollo-cache-inmemory": "1.6.5",
"apollo-client": "2.6.8",
"apollo-link-context": "1.0.19",
"apollo-link-http": "1.5.16",
"dotenv": "^8.2.0",
"graphql": "14.5.8",
"graphql-tag": "2.10.1",
"isomorphic-unfetch": "^3.0.0",
"js-cookie": "2.2.1",
"next": "9.1.7",
"react": "16.12.0",
"react-dom": "16.12.0"
Tried also the example from https://github.com/vgrafe/nextjs-auth0-hasura But never got it working with Authorization Header only with anonymous, which is not what I require.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 15 (2 by maintainers)
@tobkle @shansmith01 maybe this can help you:
lib/auth0.js
apolloClient.js
api/session.js
Steps
Auth0
Hasura
HASURA_GRAPHQL_JWT_SECRET
; config-generatorHASURA_GRAPHQL_UNAUTHORIZED_ROLE
(e.g. role ‘anonymous’)HASURA_GRAPHQL_ADMIN_SECRET
Next.js App
storeAccessToken
and addaudience
from Auth0-API (without audience no jwt token) (e.g.lib/auth0.js
)apolloClient.js
)api/session.js
)Hope that’s it 😃
Hey @Afsoon. Any chance you can share your repo please? I am also working on a project with Hasura, Apollo and Auth0, with SSR. I am going nuts figuring out a good way to pass the idToken from the backend into the apolloClient headers
Thanks
Also the examples in the folders
examples/api-call-example
in combination withexamples/sample-api
aren’t working. As soon as I setstoreIdToken: true
, I don’t get a session any more. If I have it onfalse
, I get a session, but without token. Do I need to setup a special configuration in the Auth0 Dashboard somewhere in order to get that working?