External Wallet Login
Connect wallet via the Sign in With Ethereum (SIWE) standard. Catered to users who prefer to authenticate using their external wallets, supporting various types such as injected, browser-based, and mobile wallets. Openfort’s integration facilitates a secure and direct authentication process using these wallets.
First create a challenge for the user to sign with their wallet by constructing a SIWE challenge using the nonce returned from the server:
auth.tsx
import openfort from "./openfortConfig"
const address = 'EXTERNAL_WALLET_ADDRESS';
async function initSIWE() {
await openfort.auth.initSIWE({address});
}
Then, verify the SIWE signature to authenticate the user:
walletClientType
: e.g. coinbaseWallet, metamask, etc.connectorType
: wallet_connect_v2, injected, coinbase_wallet, etc.
authSIWE.jsx
import openfort from "./openfortConfig"
const address = 'EXTERNAL_WALLET_ADDRESS';
async function authSIWE(signature, message, walletClientType, connectorType) {
await openfort.auth.authenticateWithSIWE({
signature: signature,
message: SIWEMessage,
connectorType: connector?.type,
walletClientType: connector?.name,
});
}
And you’re done! The user is now authenticated and can access your application.
Uppon successful authentication, the SDK will return a token that can be used to authenticate the user in your application.