Last active
July 19, 2019 16:09
-
-
Save CharmedSatyr/f509520216ac03a17f667795c3ae02ae to your computer and use it in GitHub Desktop.
Mastodon Social extension for Auth0
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, cb) { | |
request.get( | |
'https://[MASTODON INSTANCE URL]/api/v1/accounts/verify_credentials', { | |
headers: { | |
'Authorization': `Bearer ${accessToken}` | |
} | |
}, | |
function(err, res, body) { | |
if (err) { | |
return cb(err); | |
} | |
if (res.statusCode !== 200) { | |
return cb('statusCode: ' + res.statusCode); | |
} | |
const parsed = JSON.parse(body); | |
const profile = { | |
created_at: parsed.created_at, | |
picture: parsed.avatar, | |
nickname: parsed.display_name, | |
user_id: parsed.id, | |
username: parsed.username, | |
}; | |
cb(null, profile); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment