Management API Reference

Authentication

Linking & unlinking accounts

Manage the identities associated with your user.

The user identity represents an authentication method associated to the user. For example, if a user signs in using their email, an email identity will be associated with the user.

Developers can use Openfort to prompt users to link additional accounts (such as a wallet or Discord profile) at any point in their user journey, not just during login.

Linking accounts#

Links an email and password to an existing account using an authentication token.

auth.tsx
openfortConfig.ts

_10
import openfort from "./openfortConfig"
_10
_10
const email = 'EMAIL';
_10
const password = 'PASSWORD';
_10
const authToken = 'YOUR_USER_AUTH_TOKEN';
_10
_10
async function linkEmailPassword() {
_10
await openfort.linkEmailPassword({email, password, authToken});
_10
}

Initializes an OAuth linking process.

auth.tsx
openfortConfig.ts

_10
import openfort from "./openfortConfig"
_10
const provider = 'OAuth provider';
_10
_10
async function initLinkOAuth() {
_10
await openfort.initLinkOAuth({provider});
_10
}

Links a wallet using SIWE.

auth.tsx
openfortConfig.ts

_11
import openfort from "./openfortConfig"
_11
_11
const signature = 'SIWE signature';
_11
const message = 'SIWE message';
_11
const walletClientType = 'Wallet client type';
_11
const connectorType = 'Connector type';
_11
const authToken = 'YOUR_USER_AUTH_TOKEN';
_11
_11
async function linkWallet() {
_11
await openfort.linkWallet({signature, message, walletClientType, connectorType, authToken});
_11
}

Links a third party provider to an existing account using an authentication token.

auth.tsx

_10
import openfort from "./openfortConfig"
_10
const provider = 'Third Party provider';
_10
const token = 'Third Party token';
_10
const tokenType = 'Type of the token (idToken or customToken)'
_10
_10
async function linkThirdParty() {
_10
await openfort.linkThirdPartyProvider({provider, token, tokenType});
_10
}

Unlinking accounts#

Once a user has linked additional accounts to their profile, you may also want to give them the option to unlink those accounts.

Unlinks an email and password from an existing account using an authentication token.

auth.tsx
openfortConfig.ts

_10
import openfort from "./openfortConfig"
_10
const email = 'EMAIL';
_10
_10
async function unlinkEmailPassword() {
_10
await openfort.unlinkEmailPassword(email);
_10
}

Unlinks an OAuth provider from the account.

auth.tsx
openfortConfig.ts

_10
import openfort from "./openfortConfig"
_10
const provider = 'OAuth provider';
_10
_10
async function unLinkOAuth() {
_10
await openfort.unLinkOAuth({provider});
_10
}

Unlinks a wallet.

auth.tsx
openfortConfig.ts

_10
import openfort from "./openfortConfig"
_10
_10
const address = 'Wallet address';
_10
const authToken = 'YOUR_USER_AUTH_TOKEN';
_10
_10
async function unlinkWallet() {
_10
await openfort.unlinkWallet({provider, address});
_10
}

Unlinks a third party provider from an existing account using an authentication token.

auth.tsx
openfortConfig.ts

_10
import openfort from "./openfortConfig"
_10
const provider = 'Third Party provider';
_10
const token = 'Third Party token';
_10
const tokenType = 'Type of the token (idToken or customToken)'
_10
_10
async function unlinkThirdParty() {
_10
await openfort.unlinkThirdPartyProvider({provider, token, tokenType});
_10
}
_10
}