I want to implement user login and access some user data via the Github REST API (eg. repository, issues).
Then I successfully implemented a login feature, but the Github REST API requires a token to access its endpoints. I checked the session using getServerSession(authOptions) and obtained some information, but not the token (as shown below).
"session": {
"user": {
"name": "UserName",
"email": "[email protected]",
"image": "https://xxxxxx.xxxxxx/xxxxx"
}
}
I tried some solutions on StackOverflow but none of them worked for me.
Is there somebody who can help me? Thansk.
I found a solution in next.js Discrod server by someone's help.
docs: https://next-auth.js.org/configuration/callbacks#sign-in-callback
Then for typescript, you need to write this in "types/next-auth.d".
docs: https://next-auth.js.org/getting-started/typescript