Trusted Accounts SDK for Node.js
1. Start the Validation Flow.
Place this code on your website to show a validation button that starts the validation process. Get your platform credentials by creating a developer account for free in the developer console.
npm install --save trusted-accounts-sdk-node
import TrustedAccountsClient from 'trusted-accounts-sdk-node';
app.get('/start-verification', async (req, res) => {
const trustedClient = new TrustedAccountsClient(
"CLIENT_ID",
"REDIRECT_URL"
);
const verificationUrl = await trustedClient.generateVerificationLink(
'foo@bar.com',
);
res.redirect(verificationUrl);
});
2. Handle the Callback
After the user completes the verification, they will be redirected back to your redirect URL. Place this code on your website at this url to handle this callback and get the Trusted ID.
app.get('/callback', async (req, res) => {
const trustedId = await trustedClient.handleCallback(req, code_verifier);
res.send('Verification completed! Trusted ID: ' + trustedId);
});
That's it! You have successfully integrated Trusted Accounts on your platform! 🖖 Try validate yourself and then go to the user list in the developer console to find the newly validated user.