Skip to content

Instantly share code, notes, and snippets.

@Natim
Created November 26, 2014 11:19
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 Natim/165fbe8375aec3b5fafc to your computer and use it in GitHub Desktop.
Save Natim/165fbe8375aec3b5fafc to your computer and use it in GitHub Desktop.
FxA auth dance with Daybed
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