Created
November 26, 2014 11:19
-
-
Save Natim/165fbe8375aec3b5fafc to your computer and use it in GitHub Desktop.
FxA auth dance with Daybed
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 startFxAOauthDance(host, options) { | |
if (host === undefined) { | |
throw new Error("You should provide a host."); | |
} | |
if (options === undefined || options.redirect_uri === undefined) { | |
throw new Error("You should provide a options.redirect_uri parameter."); | |
} | |
return request({ | |
method: "POST", | |
host: host, | |
body: {redirect_uri: options.redirect_uri}, | |
url: "/tokens/fxa-oauth/params" | |
}).then(function(doc) { | |
document.location.href = doc.oauth_uri + "/authorization?" + \ | |
"client_id=" + doc.client_id + \ | |
"&state=" + doc.state + \ | |
"&scope=profile&action=signin"; | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment