Auth0
Last updated
function fetchUserProfile(accessToken, ctx, cb) {
request.post(
{
url: 'https://api.bitbadges.io/api/v0/auth/status',
headers: {
'Content-Type': 'application/json',
// TODO: Replace
'x-api-key': 'ENTER_API_KEY_HERE',
Authorization: 'Bearer ' + accessToken,
},
},
(err, resp, body) => {
if (err) {
return cb(err);
}
if (resp.statusCode !== 200) {
return cb(new Error(body));
}
let bodyParsed;
try {
bodyParsed = JSON.parse(body);
} catch (jsonError) {
return cb(
new Error('Failed JSON parsing for user profile response.')
);
}
const account = bodyParsed;
const profile = {
address: account.address,
chain: account.chain,
id: account.bitbadgesAddress,
name: account.address,
};
return cb(null, profile);
}
);
}{
"x-api-key": "YOUR_API_KEY"
}