Optional
options: GetAccessTokenOptionsForce a refresh of the access token.
getAccessToken returns the access token.
This method can be used in middleware and getServerSideProps
, API routes in the Pages Router.
The request object.
The response object.
Optional
options: GetAccessTokenOptionsOptional configuration for getting the access token.
Force a refresh of the access token.
Retrieves an access token for a connection.
This method can be used in Server Components, Server Actions, and Route Handlers in the App Router.
NOTE: Server Components cannot set cookies. Calling getAccessTokenForConnection()
in a Server Component will cause the access token to be refreshed, if it is expired, and the updated token set will not to be persisted.
It is recommended to call getAccessTokenForConnection(req, res)
in the middleware if you need to retrieve the access token in a Server Component to ensure the updated token set is persisted.
Retrieves an access token for a connection.
This method can be used in middleware and getServerSideProps
, API routes in the Pages Router.
getSession returns the session data for the current request.
This method can be used in Server Components, Server Actions, and Route Handlers in the App Router.
getSession returns the session data for the current request.
This method can be used in middleware and getServerSideProps
, API routes in the Pages Router.
middleware mounts the SDK routes to run as a middleware function.
updateSession updates the session of the currently authenticated user. If the user does not have a session, an error is thrown.
This method can be used in middleware and getServerSideProps
, API routes, and middleware in the Pages Router.
updateSession updates the session of the currently authenticated user. If the user does not have a session, an error is thrown.
This method can be used in Server Actions and Route Handlers in the App Router.
Optional configuration for getting the access token.