Skip to content

Linking & unlinking accounts

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

Link email

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

import openfort from "./openfortConfig"
 
const email = 'EMAIL';
const password = 'PASSWORD';
const authToken = 'YOUR_USER_AUTH_TOKEN';
 
async function linkEmailPassword() {
  await openfort.auth.linkEmailPassword({email, password, authToken});
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;

Link social accounts

Initializes an OAuth linking process.

import openfort from "./openfortConfig"
const provider = 'OAuth provider';
 
async function initLinkOAuth() {
  await openfort.auth.initLinkOAuth({provider});
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;

Link wallets

Links a wallet using SIWE.

import openfort from "./openfortConfig"
 
const signature = 'SIWE signature';
const message = 'SIWE message';
const walletClientType = 'Wallet client type';
const connectorType = 'Connector type';
const authToken = 'YOUR_USER_AUTH_TOKEN';
 
async function linkWallet() {
  await openfort.auth.linkWallet({signature, message, walletClientType, connectorType, authToken});
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;

Link third party providers

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

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

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.

Unlink email

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

import openfort from "./openfortConfig"
const email = 'EMAIL';
 
async function unlinkEmailPassword() {
  await openfort.auth.unlinkEmailPassword(email);
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;

Unlink social accounts

Unlinks an OAuth provider from the account.

import openfort from "./openfortConfig"
const provider = 'OAuth provider';
 
async function unLinkOAuth() {
  await openfort.auth.unlinkOAuth({provider});
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;

Unlink wallets

Unlinks a wallet.

import openfort from "./openfortConfig"
 
const address = 'Wallet address';
const authToken = 'YOUR_USER_AUTH_TOKEN';
 
async function unlinkWallet() {
  await openfort.auth.unlinkWallet({provider, address});
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;

Unlink third party provider

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

import openfort from "./openfortConfig"
const provider = 'Third Party provider';
const token = 'Third Party token';
const tokenType = 'Type of the token (idToken or customToken)'
 
async function unlinkThirdParty() {
  await openfort.unlinkThirdPartyProvider({provider, token, tokenType});
}
import Openfort from '@openfort/openfort-js';
 
const openfort = new Openfort({
  baseConfiguration: {
    publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
  }
});
 
export default openfort;