mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
268 lines
6.5 KiB
YAML
268 lines
6.5 KiB
YAML
openref: 0.1
|
|
|
|
info:
|
|
title: GoTrue Client
|
|
description: |
|
|
GoTrue is an authentication server.
|
|
|
|
Supabase provides client libraries to interact with the server
|
|
|
|
definition: spec/gotrue.json
|
|
libraries:
|
|
- name: 'JavaScript'
|
|
id: 'js'
|
|
version: '0.0.1'
|
|
- name: 'Python'
|
|
id: 'py'
|
|
version: '0.0.1'
|
|
docs:
|
|
path: gotrue/client/
|
|
sidebar:
|
|
- name: 'About'
|
|
items:
|
|
- index
|
|
- Installing
|
|
- Initializing
|
|
- name: 'Client functions'
|
|
items:
|
|
- signUp
|
|
- signIn
|
|
- signOut
|
|
- user
|
|
- session
|
|
- update
|
|
- onAuthStateChange
|
|
- name: 'General functions'
|
|
items:
|
|
- api.signUpWithEmail
|
|
- api.signInWithEmail
|
|
- api.sendMagicLinkEmail
|
|
- api.inviteUserByEmail
|
|
- api.resetPasswordForEmail
|
|
- api.signOut
|
|
- api.getUser
|
|
- api.updateUser
|
|
- api.refreshAccessToken
|
|
|
|
pages:
|
|
Installing:
|
|
description: |
|
|
All JavaScript libraries are built directly by the Supabase team.
|
|
|
|
Other languages are built by the community and supported by Supabase.
|
|
|
|
## JavaScript
|
|
|
|
```bash
|
|
npm install @supabase/gotrue-js
|
|
```
|
|
|
|
## Python
|
|
|
|
```bash
|
|
# Not yet implemented
|
|
```
|
|
|
|
Initializing:
|
|
$ref: '"GoTrueClient".GoTrueClient.constructor'
|
|
examples:
|
|
- name: Initialize a GoTrue client
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
import { GoTrueClient } from '@supabase/gotrue-js'
|
|
|
|
const auth = new GoTrueClient({
|
|
url: "https://your-gotrue-url.com",
|
|
headers: {
|
|
apikey:
|
|
"<SOME-API-KEY>",
|
|
Authorization:
|
|
"Bearer <SOME-JWT>",
|
|
},
|
|
})
|
|
```
|
|
py: |
|
|
```py
|
|
# Not yet implemented
|
|
```
|
|
|
|
signUp:
|
|
$ref: '"GoTrueClient".GoTrueClient.signUp'
|
|
notes: |
|
|
- A user can sign up either via email or OAuth.
|
|
- If you provide `email`, `password` is also required
|
|
- If you provide `access_token`, `password` is also required
|
|
examples:
|
|
- name: Sign up
|
|
js: |
|
|
```js
|
|
const { error, data } = await auth.signUp({
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
})
|
|
```
|
|
py: |
|
|
```py
|
|
# Not yet implemented
|
|
```
|
|
|
|
signIn:
|
|
$ref: '"GoTrueClient".GoTrueClient.signIn'
|
|
examples:
|
|
- name: Sign in
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
// with email and password
|
|
const { user, error } = await auth.signIn({
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
})
|
|
|
|
// send magic link (passwordless link)
|
|
const { user, error } = await auth.signIn({
|
|
email: 'example@email.com',
|
|
})
|
|
```
|
|
py: |
|
|
```py
|
|
# Not yet implemented
|
|
```
|
|
|
|
signOut:
|
|
$ref: '"GoTrueClient".GoTrueClient.signOut'
|
|
examples:
|
|
- name: Sign out
|
|
js: |
|
|
```js
|
|
const { error } = await auth.signOut()
|
|
```
|
|
|
|
user:
|
|
$ref: '"GoTrueClient".GoTrueClient.user'
|
|
examples:
|
|
- name: Get user
|
|
js: |
|
|
```js
|
|
const user = auth.user()
|
|
```
|
|
|
|
session:
|
|
$ref: '"GoTrueClient".GoTrueClient.session'
|
|
examples:
|
|
- name: Get user
|
|
js: |
|
|
```js
|
|
const session = auth.session()
|
|
```
|
|
|
|
update:
|
|
$ref: '"GoTrueClient".GoTrueClient.update'
|
|
examples:
|
|
- name: Update a user's metadata.
|
|
isSpotlight: true
|
|
js: |
|
|
```js
|
|
const { user, error } = await auth.update({
|
|
data: { hello: 'world' }
|
|
})
|
|
```
|
|
py: |
|
|
```py
|
|
# Not yet implemented
|
|
```
|
|
|
|
onAuthStateChange:
|
|
# $ref: onAuthStateChange
|
|
|
|
api.signUpWithEmail:
|
|
$ref: '"GoTrueApi".GoTrueApi.signUpWithEmail'
|
|
examples:
|
|
- name: Sign up a new user with email
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.signUpWithEmail('example@email.com', 'example-password')
|
|
```
|
|
|
|
api.signInWithEmail:
|
|
$ref: '"GoTrueApi".GoTrueApi.signInWithEmail'
|
|
examples:
|
|
- name: Sign in a user with email
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.signInWithEmail('example@email.com', 'example-password')
|
|
```
|
|
|
|
api.sendMagicLinkEmail:
|
|
$ref: '"GoTrueApi".GoTrueApi.sendMagicLinkEmail'
|
|
examples:
|
|
- name: Send user a passwordless login link via email
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.sendMagicLinkEmail('example@email.com')
|
|
```
|
|
|
|
api.inviteUserByEmail:
|
|
$ref: '"GoTrueApi".GoTrueApi.inviteUserByEmail'
|
|
examples:
|
|
- name: Send a user an invite link to sign up via email
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.inviteUserByEmail('example@email.com')
|
|
```
|
|
|
|
api.resetPasswordForEmail:
|
|
$ref: '"GoTrueApi".GoTrueApi.resetPasswordForEmail'
|
|
examples:
|
|
- name: Send a user a password reset email
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.resetPasswordForEmail('example@email.com')
|
|
```
|
|
|
|
api.signOut:
|
|
$ref: '"GoTrueApi".GoTrueApi.signOut'
|
|
examples:
|
|
- name: Sign a user out
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.signOut(access_token)
|
|
```
|
|
|
|
api.getUser:
|
|
$ref: '"GoTrueApi".GoTrueApi.getUser'
|
|
examples:
|
|
- name: Get the user details for a given user
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.getUser(access_token)
|
|
```
|
|
|
|
api.updateUser:
|
|
$ref: '"GoTrueApi".GoTrueApi.updateUser'
|
|
examples:
|
|
- name: Update user info that Gotrue holds (also used for setting new passwords)
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.updateUser(access_token, { password : 'Why Shinji?' })
|
|
```
|
|
|
|
api.refreshAccessToken:
|
|
$ref: '"GoTrueApi".GoTrueApi.refreshAccessToken'
|
|
examples:
|
|
- name: Get a new access and refresh token using a valid refresh_token
|
|
js: |
|
|
```js
|
|
const { error, data } = await api
|
|
.refreshAccessToken(refresh_token)
|
|
```
|