Last active
June 20, 2022 10:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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