๐งพ Node.js
1. Install the SDKโ
npm install --save trusted-accounts-sdk-node
2. Start the User Validation Flowโ
Get your platform credentials free in the developer console.
import TrustedAccountsClient from 'trusted-accounts-sdk-node';
const taClient = new TrustedAccountsClient(
"CLIENT_ID", // Your Client ID
"CLIENT_SECRET", // Your Client SECRET
"REDIRECT_URL" // Your Redirect URI
);
app.get('/start-verification', async (req, res) => {
// Generate the verification URL
const verificationUrl = await taClient.generateAuthorizationUrl(
'foo@bar.com', // The email of the user you want to validate
);
// Redirect the user to the verification page
// or create a verification button to trigger it manually
res.redirect(verificationUrl);
});
3. 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) => {
// Get the Trusted ID
const trustedId = await taClient.handleCallback(req.query.code);
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.