Set the session data
Sets the session data from the current session. If the current session is expired, setSession will take care of refreshing it to obtain a new session. If the refresh token or access token in the current session is invalid, an error will be thrown.
setSession()
takes in a refresh token and uses it to get a new session.- The refresh token can only be used once to obtain a new session.
- Refresh token rotation is enabled by default on all projects to guard against replay attacks.
- You can configure the
REFRESH_TOKEN_REUSE_INTERVAL
which provides a short window in which the same refresh token can be used multiple times in the event of concurrency or offline issues.
Parameters
- currentSessionREQUIREDobject
The current session that minimally contains an access token and refresh token.
refresh_tokenREQUIREDstringaccess_tokenREQUIREDstring
const { data, error } = supabase.auth.setSession({
access_token,
refresh_token
})