Skip to content

Instantly share code, notes, and snippets.

@gseguin
Last active December 29, 2015 11:19
Show Gist options
  • Save gseguin/7663235 to your computer and use it in GitHub Desktop.
Save gseguin/7663235 to your computer and use it in GitHub Desktop.
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