Open kiitosu opened 1 month ago
Hi @kiitosu - The access token is being set using the following snippet here - https://github.com/hasura/learn-graphql/blob/5e19739d128a62ce0989810a2f74334e52d80e8e/tutorials/frontend/react-apollo-hooks/app-final/src/hooks/useAccessToken.js#L13
const getAccessToken = async () => {
const { audience, scope } = AUTH_CONFIG;
try {
const accessToken = await getAccessTokenSilently({
audience,
scope,
});
setIdToken(accessToken);
} catch (e) {
console.log(e.message);
}
};
I would start debugging there. Quick caveat: The tutorial is using older versions of Auth0 SDK, so I would double-check if it is using the right one since newer ones may have breaking changes. Meanwhile, I will try running it from my side to see what could be wrong.
I followed frontend tutorial graphql with react https://hasura.io/learn/graphql/react/introduction/. And I get authentication error with token I get with useAccessToken.
Base code I used is https://github.com/hasura/learn-graphql/commit/698f187e0999ffeae85d81e57af141bcffd729db. Error message is "[GraphQL error]: Authentication hook unauthorized this request " at TodoPrivateList.js:66.
When I hard code jwt like below that is gotten at https://hasura.io/learn/graphql/graphiql, I can query in localhost web site with npm start.
Why I get authentication error with token I get with useAccessToken? How can I handle token?
Diff patch is below.
TodoPrivateList.js
App.js