Accessing provider credentials using database sessions #2161
-
Hi folks! I am using Okta as a provider, and I need the access token it returns to call their REST API in my server-side API routes. I'm using database sessions to persist user sessions in MongoDB. I can see by inspecting the database that the access token for the provider is stored in the I've been scouring the documentation, Google, and this discussion board for the answer to this question, so hopefully I'm not just missing something. What is the expected and "correct" way to access the information from the Persist the data from login using the
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So according to our FAQ, if you don't persist the access token in the session then you have to look it up from the database yourself. I assume this is because in serverless environments, the cookie is really the only way to persist data without accessing a database. https://next-auth.js.org/faq#how-do-i-get-refresh-tokens-and-access-tokens-for-an-oauth-account Hope this helps. |
Beta Was this translation helpful? Give feedback.
So according to our FAQ, if you don't persist the access token in the session then you have to look it up from the database yourself. I assume this is because in serverless environments, the cookie is really the only way to persist data without accessing a database.
https://next-auth.js.org/faq#how-do-i-get-refresh-tokens-and-access-tokens-for-an-oauth-account
Hope this helps.