Struct supabase_auth::client::AuthClient
source · pub struct AuthClient {
pub client: Client,
pub project_url: String,
pub api_key: String,
pub jwt_secret: String,
}
Expand description
Supabase Auth Client
You can find your project url and keys at https://supabase.com/dashboard/project/
Fields§
§client: Client
§project_url: String
REST endpoint for querying and managing your database
Example: https://
api_key: String
WARN: The service role
key has the ability to bypass Row Level Security. Never share it publicly.
jwt_secret: String
Used to decode your JWTs. You can also use this to mint your own JWTs.
Implementations§
source§impl AuthClient
impl AuthClient
sourcepub fn new(
project_url: impl Into<String>,
api_key: impl Into<String>,
jwt_secret: impl Into<String>,
) -> Self
pub fn new( project_url: impl Into<String>, api_key: impl Into<String>, jwt_secret: impl Into<String>, ) -> Self
Create a new AuthClient
sourcepub fn new_from_env() -> Result<AuthClient, Error>
pub fn new_from_env() -> Result<AuthClient, Error>
Create a new AuthClient from environment variables
Requires SUPABASE_URL
, SUPABASE_API_KEY
, and SUPABASE_JWT_SECRET
environment variables
pub async fn sign_in_with_email_and_password<S: Into<String>>( &self, email: S, password: S, ) -> Result<Session, Error>
pub async fn sign_in_with_phone_and_password<S: Into<String>>( &self, phone: S, password: S, ) -> Result<Session, Error>
pub async fn sign_up_with_email_and_password<S: Into<String>>( &self, email: S, password: S, ) -> Result<Session, Error>
pub async fn sign_up_with_phone_and_password<S: Into<String>>( &self, phone: S, password: S, ) -> Result<Session, Error>
pub async fn send_login_email_with_magic_link<S: Into<String>>( &self, email: S, ) -> Result<Response, Error>
pub async fn send_sms_with_otp<S: Into<String>>( &self, phone: S, ) -> Result<Response, Error>
pub async fn send_email_with_otp<S: Into<String>>( &self, email: S, options: Option<SignInEmailOtpParams>, ) -> Result<Response, Error>
pub async fn sign_in_with_oauth( &self, provider: Provider, ) -> Result<Response, Error>
sourcepub async fn get_user<S: Into<String>>(
&self,
bearer_token: S,
) -> Result<User, Error>
pub async fn get_user<S: Into<String>>( &self, bearer_token: S, ) -> Result<User, Error>
Get the User struct of the logged in user
sourcepub async fn forgotten_password_email<S: Into<String>>(
&self,
email: S,
) -> Result<(), Error>
pub async fn forgotten_password_email<S: Into<String>>( &self, email: S, ) -> Result<(), Error>
Sends the user a log in link via email. Once logged in you should direct the user to a new password form. And use “Update User” below to save the new password.
sourcepub async fn update_user<S: Into<String>>(
&self,
updated_user: UpdateUserPayload,
bearer_token: S,
) -> Result<User, Error>
pub async fn update_user<S: Into<String>>( &self, updated_user: UpdateUserPayload, bearer_token: S, ) -> Result<User, Error>
Update the user with a new email or password. Each key (email, password, and data) is optional
sourcepub async fn sign_in_with_id_token(
&self,
credentials: SignInWithIdTokenCredentials,
) -> Result<Session, Error>
pub async fn sign_in_with_id_token( &self, credentials: SignInWithIdTokenCredentials, ) -> Result<Session, Error>
Allows signing in with an OIDC ID token. The authentication provider used should be enabled and configured.
sourcepub async fn invite_user_by_email<S: Into<String>>(
&self,
email: S,
) -> Result<User, Error>
pub async fn invite_user_by_email<S: Into<String>>( &self, email: S, ) -> Result<User, Error>
Sends an invite link to an email address.