Manual "code" exchange into access_token with external backend API using Google Provider #12641
Unanswered
bagusadlan
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
-
the OAuth flow generally has 6 parts:
I want to grab code from GET "api/auth/callback/github?code=123" manually, then post it into my external backend API to validate there and get the access_token.
app/api/auth/callback/github/route.ts
The fact is, I have no idea where to put fetch to external backend API, in
app/api/auth/callback/github/route.ts
,Nextjs middleware
ornext-auth callbacks
. All I know isapp/api/auth/callback/github/route.ts
called first thennext-auth callbacks
after. If we want to add more to the session (like access_token) we have to do it innext-auth session callbacks
.Is anyone know how to do all that? Grab the code and validate manually, add
access_token
into session, then redirect into page where I passed it when call the login functionOr should I use a Custom Provider?
Beta Was this translation helpful? Give feedback.
All reactions