#token stuff

1 messages ยท Page 1 of 1 (latest)

grand furnace
#

you basically send a token AND refresh token with the initial auth.

#

if the auth token gets destroyed or invalidated from the server (e.g. logout on other device),

#

you can fetch the auth -> check if valid -> if not send auth with refresh token.

#

this refresh token will act like a valid login and provides a new auth for the user (authToken and NEW refreshToken)

#

if you want to completely disconnect the auth. you just kill the refresh token in the db aswell

#

this way you can manage multiple devices if they all logged in with an active session of the user

charred marlin
#

@grand furnace I only use auth0 in nexxtjs frontend
I don`t use any db for this auth0

grand furnace
#

well sorry, xD misread oauth !== auth0

charred marlin
#

In order to get token expiration, I sent request and got response , 401 error , in this case, I got refresh token
how to get easily token expiration?
it is auth0

grand furnace
#

here ya go

#

1ms google search ๐Ÿ˜‰

charred marlin
#

so if I use refresh token, then it is not expired?
or should I use refresh token when access token is expired?

grand furnace
#

do you read? ๐Ÿ˜„ ๐Ÿ˜„

#

first sentence on the page ๐Ÿ˜„

charred marlin
#

How to get know token expired

#

?

grand furnace
#

401 == 'Not authorized'?

charred marlin
#

Yes

grand furnace
#

if you request a page when you where logged in, you get a 401, that means your access has expired

#

if that happens

#

so you basically wrap your calls in

#

request.then(code => if (code == 401) return new refreshRequest().then(originalRequest.then(return response))).then(return response)

charred marlin
#

I have multiple pages and I only use frontend with nexdtjs

#

this is my _app.js

grand furnace
#

i never used auth0 and this convo gets to detailed for me, i have other stuff to do. The docs should provide what you need in 99% of the cases.

charred marlin
#

ok , thanks

#

anyway hope to see you again

grand furnace
#

im on the server ๐Ÿ™‚ lemme know if it works later on

#

this might be intersting for ya