Next.js Discord

Discord Forum

NextAuth in NextJS App Router with Google Calender API

Answered
Carolina Dog posted this in #help-forum
Open in Discord
Carolina DogOP
For now, is NextAuth supported in NextJS App Router? And if so, can I connect it with google calendar API? Thanks.
Answered by tafutada777
yes, it is possible. you are lucky as i was just playing around with next-auth with App Router. Here is my codes available at

https://github.com/tfutada/zenn-nextjs/tree/main
View full answer

10 Replies

yes, it is possible. you are lucky as i was just playing around with next-auth with App Router. Here is my codes available at

https://github.com/tfutada/zenn-nextjs/tree/main
Answer
you can get user's google access token with token.accessToken from session, so you can pass it to Google API, oauth2Client.setCredentials(tokens);
. i am not sure about Google API though.
Carolina DogOP
Okayy Thank you!
@tafutada777 you can get user's google access token with token.accessToken from session, so you can pass it to Google API, oauth2Client.setCredentials(tokens); . i am not sure about Google API though.
Carolina DogOP
"you can get user's google access token with token.accessToken from session"
This means the code runs on client side right? I tried using getToken in the server component, but I don't know how to convert it from type JWT to type string.
see options.ts where the token is set as session.user.accessToken
keep in mind that you can store an accessToken from Google in a JWT token as a property. The JWT can contain other properties as well as the accessToken. look carefully at options.ts
accessToken here is a provider token, namely Google issued token. JWT is a token you issued which is stored as a cookie.
@Carolina Dog i implemented Google Calendar API. it works fine. check out the latest commit.
@tafutada777 <@348294011368374285> i implemented Google Calendar API. it works fine. check out the latest commit.
Carolina DogOP
Okay Thankss, although I already successfully implemented it Thank you for your help!