Verification Flow
// 32 byte hex string
async function myHandler(req: NextApiRequest, res: NextApiResponse) {
const code = req.query.code as string;
}// 32 byte hex string
async function myHandler(req: NextApiRequest, res: NextApiResponse) {
const code = req.query.code as string;
const options = {
issuedAtTimeWindowMs: 1000 * 60 * 10, // 10 minutes (set to 0 to disable)
};
// POST https://api.bitbadges.io/api/v0/siwbb/token
const res = await BitBadgesApi.exchangeSIWBBAuthorizationCode({
code,
options,
grant_type: 'authorization_code',
client_secret: '...',
client_id: '...',
redirect_uri: '...', //only needed for digital immediate flow
});
const { address, chain, verificationResponse } = res;
if (!verificationResponse.success) {
console.log(verificationResponse.errorMessage);
throw new Error('Not authenticated');
}
//Verify claims or anything else you need to do here
}IMPORTANT: What is verified natively vs not?
Last updated