"" let serviceToken = ""; let url = process.en...
# support-questions
d
"" let serviceToken = ""; let url = process.env.NEXT_PUBLIC_APP_URL + "/api/auth/signin"; let options = { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, credentials: 'include', body: '{"formFields":[{"id":"email","value":"some@user.name"},{"id":"password","value":"password"}]}' }; await fetch(url, options) .then(res => res.headers.raw() ) .then(json => json["front-token"]) .then(token => serviceToken = token[0]) .catch(err => res.status(500).json({'error:': err})); console.log(serviceToken); ""
r
hey @DuC
d
Hi 🙂
r
what are you trying to do exactly?
d
I have a working login inside my fronendpart of my NextJs application. But I made a service user, and want to insert data into a hasura instance with a backend api route. This one is triggered by a cronjob hasura to nextjs API service... In the service, I need to first fetch a valid token from supertokes auth server. Then use it in a apolloclient to mutate data back into hasura.
But when i login with the fetch / insomina post to /auth/signin. None of the tokens that are returned are valdid tokens when i check them in jwt.io or hasura Authorization header in console.
r
right. Checkout our docs for how to use our sessions with JWT
d
Thank you.
2 Views