Skip to main content
Module

x/supabase/mod.ts>GoTrueApi

An isomorphic Javascript client for Supabase.
Go to Latest
class GoTrueApi
Re-export
import { GoTrueApi } from "https://deno.land/x/supabase@1.3.1/mod.ts";

Constructors

new
GoTrueApi(unnamed 0: { url: string; headers?: { [key: string]: string; }; cookieOptions?: CookieOptions; })

Properties

protected
cookieOptions: CookieOptions
protected
headers: { [key: string]: string; }
protected
url: string

Methods

private
_createRequestHeaders(jwt: string)

Create a temporary object with all configured headers and adds the Authorization token to be used on request methods

deleteUser(uid: string, jwt: string): Promise<{ user: User | null; data: User | null; error: ApiError | null; }>

Delete a user. Requires a service_role key.

This function should only be called on a server. Never expose your service_role key in the browser.

getUrlForProvider(provider: Provider, options: { redirectTo?: string; scopes?: string; })

Generates the relevant login URL for a third-party provider.

getUser(jwt: string): Promise<{ user: User | null; data: User | null; error: ApiError | null; }>

Gets the user details.

getUserByCookie(req: any): Promise<{ user: User | null; data: User | null; error: Error | null; }>

Get user by reading the cookie from the request. Works for Next.js & Express (requires cookie-parser middleware).

inviteUserByEmail(email: string, options?: { redirectTo?: string; data?: Record<string, unknown>; }): Promise<{ data: User | null; error: ApiError | null; }>

Sends an invite link to an email address.

refreshAccessToken(refreshToken: string): Promise<{ data: Session | null; error: ApiError | null; }>

Generates a new JWT.

resetPasswordForEmail(email: string, options?: { redirectTo?: string; }): Promise<{ data: Record<string, unknown> | null; error: ApiError | null; }>

Sends a reset request to an email address.

sendMagicLinkEmail(email: string, options?: { redirectTo?: string; }): Promise<{ data: Record<string, unknown> | null; error: ApiError | null; }>

Sends a magic login link to an email address.

sendMobileOTP(phone: string): Promise<{ data: { } | null; error: ApiError | null; }>

Sends a mobile OTP via SMS. Will register the account if it doesn't already exist

setAuthCookie(req: any, res: any)

Set/delete the auth cookie based on the AuthChangeEvent. Works for Next.js & Express (requires cookie-parser middleware).

signInWithEmail(
email: string,
password: string,
options?: { redirectTo?: string; },
): Promise<{ data: Session | null; error: ApiError | null; }>

Logs in an existing user using their email address.

signInWithPhone(phone: string, password: string): Promise<{ data: Session | null; error: ApiError | null; }>

Logs in an existing user using their phone number and password.

signOut(jwt: string): Promise<{ error: ApiError | null; }>

Removes a logged-in session.

signUpWithEmail(
email: string,
password: string,
options?: { redirectTo?: string; data?: Record<string, unknown>; },
): Promise<{ data: Session | User | null; error: ApiError | null; }>

Creates a new user using their email address.

signUpWithPhone(
phone: string,
password: string,
options?: { data?: Record<string, unknown>; },
): Promise<{ data: Session | User | null; error: ApiError | null; }>

Signs up a new user using their phone number and a password.

updateUser(jwt: string, attributes: UserAttributes): Promise<{ user: User | null; data: User | null; error: ApiError | null; }>

Updates the user data.

verifyMobileOTP(
phone: string,
token: string,
options?: { redirectTo?: string; },
): Promise<{ data: Session | User | null; error: ApiError | null; }>

Send User supplied Mobile OTP to be verified