Skip to main content

Account

login

Prompts the user to login if they are not logged in. If an OAuth verifier is not provided, a modal selector will be shown.

await torus.login(params);

Parameters

  • params - LoginParams (optional) : The login options. Used to specify a type of login
    • verifier - enum : The OAuth verifier name. Supported options for verifier are google facebook twitch reddit discord

Returns

  • Promise<string[]> : Returns a promise which resolves to the Solana addresses associated with the user.

Reference

interface LoginParams {
verifier?: "google" | "facebook" | "twitch" | "reddit" | "discord";
}

Examples

await torus.login();

logout

Logs the user out of Torus. Requires that a user is logged in already.

await torus.logout();

Returns

  • Promise<void> : Returns a promise which resolves to void. Rejects if the user is not logged in.

Examples

await torus.logout();

getUserInfo

Returns the logged-in user's info including name, email, and imageUrl. Only works if the user is logged in.

const userInfo = await torus.getUserInfo();

Returns

  • Promise<UserInfo> : Returns a promise which resolves to UserInfo object.

Reference

interface UserInfo {

email: string,
name: string,
profileImage: string,
aggregateVerifier: string,
verifier: string,
verifierId: string,
typeOfLogin: string,
}

Examples

const userInfo = await torus.getUserInfo();