Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Merge pull request #9756 from Aerilym/master

dng7be2ab9031ff
diff --cc spec/supabase_js_v2.yml
index c3ee9260119,70bf0eec996..070741bb0b8
--- a/spec/supabase_js_v2.yml
+++ b/spec/supabase_js_v2.yml
@@@ -333,38 -333,18 +333,38 @@@ pages
title: 'setSession()'
$ref: '@supabase/gotrue-js.GoTrueClient.setSession'
notes: |
- - `setSession()` takes in a refresh token and uses it to get a new session.
+ - `setSession()` takes in a refresh token and access 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 (see [`REFRESH_TOKEN_ROTATION_ENABLED`](https://supabase.com/docs/reference/auth/config#refresh_token_rotation_enabled)) is enabled by default on all projects to guard against replay attacks.
+ - [Refresh token rotation](/docs/reference/auth/config#refresh_token_rotation_enabled) is enabled by default on all projects to guard against replay attacks.
- You can configure the [`REFRESH_TOKEN_REUSE_INTERVAL`](https://supabase.com/docs/reference/auth/config#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.
+ - If you are using React Native, you will need to install a Buffer polyfill via a library such as [rn-nodeify](https://github.com/tradle/rn-nodeify) to properly use the library.
examples:
- - name: Refresh the session
- description: Sets the session data from refresh_token and returns current session or an error if the refresh_token is invalid.
+ - name: Set the session
+ description: Sets the session data from a refresh_token and access_token and returns current session or an error if the tokens are invalid.
isSpotlight: true
js: |
```js
- const { data, error } = supabase.auth.setSession(refresh_token)
+ const { data, error } = supabase.auth.setSession({refresh_token, access_token})
```
+ auth.refreshSession():
+ title: 'refreshSession()'
+ $ref: '@supabase/gotrue-js.GoTrueClient.refreshSession'
+ notes: |
+ - This method will refresh the session whether the current one is expired or not.
+ - Both examples destructure `user` and `session` from `data`. This is not required; so `const { data, error } =` is also valid.
+ examples:
+ - name: Refresh session using the current session
+ isSpotlight: true
+ js: |
+ ```js
+ const { data: { user, session }, error } = await supabase.auth.refreshSession()
+ ```
+ - name: Refresh session using a passed-in session
+ isSpotlight: true
+ js: |
+ ```js
+ const { data: { user, session }, error } = await supabase.auth.refreshSession({ refresh_token })
+ ```
auth.onAuthStateChange():
title: 'onAuthStateChange()'
$ref: '@supabase/gotrue-js.GoTrueClient.onAuthStateChange'