Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active June 20, 2022 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WietseWind/79293079ab09b693be45f0b36557110c to your computer and use it in GitHub Desktop.
Save WietseWind/79293079ab09b693be45f0b36557110c to your computer and use it in GitHub Desktop.
Xumm OAuth2 Sign In for Auth0, based on Developer Question: https://xumm.readme.io/discuss/62af82ada6faf1007c0e89f3
function(accessToken, ctx, callback) {
const url = "https://oauth2.xumm.app/userinfo";
request.get(
{ url, headers: { 'Authorization': 'Bearer ' + accessToken, } },
(err, resp, body) => {
if (err) {
return callback(err);
}
if (resp.statusCode !== 200) {
return callback(new Error(body));
}
let bodyParsed;
try {
bodyParsed = JSON.parse(body);
} catch (jsonError) {
return callback(new Error(body));
}
const profile = {
user_id: bodyParsed.sub,
email: bodyParsed.email,
name: bodyParsed.name,
kycApproved: bodyParsed.kycApproved,
proSubscription: bodyParsed.proSubscription,
picture: bodyParsed.picture,
};
callback(null, profile);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment