Last active
December 29, 2015 11:19
-
-
Save gseguin/7663235 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
function arno(){ | |
/* | |
* check for authenticated user | |
*/ | |
var schema = null; | |
var profile = null; | |
if (params["access_token"]) { | |
/* | |
* Set up once and for all | |
*/ | |
$.ajaxSetup({ headers: { 'Authorization': 'Bearer '+params["access_token"] } }); | |
/* | |
* grab the schema for the authenticated user | |
*/ | |
var schemaPromise = $.get("/dataview/Schemas.json").then( | |
function(data){ | |
$.each(data.Resources, | |
function(resourceIndex,resourceValue){ | |
if (resourceValue.name == "Self" ){ | |
schema = resourceValue.attributes; | |
} | |
} | |
); | |
} | |
).promise(); | |
/* | |
* Grab self profile data | |
*/ | |
var profilePromise = $.get("/dataview/Self/Self.json").then( | |
function(data){ | |
profile=data; | |
} | |
).promise(); | |
/* | |
*Render the profile once we have both response from the SCIM view | |
*/ | |
$.when(schemaPromise, profilePromise).done(function() { | |
renderProfile(profile,schema) | |
}); | |
} else if (params["error"]) { | |
displayError(params["error"] + ": " + params["error_description"]); | |
} else { | |
window.location="/oauth/authorize?response_type=token&client_id="+id | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment