Skip to content

Instantly share code, notes, and snippets.

@CharmedSatyr
Last active July 19, 2019 16:09
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 CharmedSatyr/f509520216ac03a17f667795c3ae02ae to your computer and use it in GitHub Desktop.
Save CharmedSatyr/f509520216ac03a17f667795c3ae02ae to your computer and use it in GitHub Desktop.
Mastodon Social extension for Auth0
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