Authentication with another server oauth2 #5311
Unanswered
shahryarjb
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have a problem that I have searched in this place and Stack Overflow, but I could not be able to fix it.
I have an API which is located in another host and server, and it is not a
NextJS
API. When I send a request to the server, I receive a JSON like this:So I need to store the {
access_token
,access_expires_in
,refresh_expires_in
,refresh_token
}.access_token
token expires every hourrefresh_token
token expires every 14 daysIn my page, my user sends a form like this:
And the API part in
NextJs
I know the token, it is not stored in
session
but I need to catch it in my callback to store insession
, something like this:The first problem I have is I get an error like this:
Cannot read properties of undefined (reading 'token')
, for example the part I dotoken.access_token = user.token.access_token;
, it can not readuser.token
When I
console.log(user)
I getIt loads 2 time and the second time
token
is not there and my code is broken.If I change the JWT call back to this, It works:
The second problem is, The
next-auth
has own expires time, but I need it works 14 days and keep the refresh token and let user get new access with refresh token helpPlease help me how can get token and set it and if you have suggestion for me let me know what I should do
Thank you in advance, and Thank you again for all your efforts
Beta Was this translation helpful? Give feedback.
All reactions