Last active
October 24, 2019 22:24
-
-
Save gdestuynder/4c3bbf0b35664a109720436cfe3bd17b to your computer and use it in GitHub Desktop.
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
var request = require("request"); | |
// Exchange credentials for a temporary access token (valid 1h) | |
var options = { method: 'POST', | |
url: 'https://auth.mozilla.auth0.com/oauth/token', | |
headers: { 'content-type': 'application/json' }, | |
body: '{"client_id":"CLIENT ID GOES HERE","client_secret":"SECRET GOES HERE","audience":"api.sso.mozilla.com","grant_type":"client_credentials"}' }; | |
request(options, function (error, response, token) { | |
if (error) throw new Error(error); | |
// Talk to the API | |
// See https://github.com/mozilla-iam/cis/blob/master/docs/PersonAPI.md for more examples / routes | |
options = { method: 'GET', | |
url: 'https://person.api.sso.mozilla.com/v2/user/primary_email/gdestuynder@mozilla.com', | |
headers: { authorization: 'Bearer '+token.access_token } }; | |
request(options, function (error, response, body) { | |
if (error) throw new Error(error); | |
console.log(body); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment