Skip to content

Instantly share code, notes, and snippets.

@rfaisal
Created March 1, 2014 21:22
Show Gist options
  • Select an option

  • Save rfaisal/9297579 to your computer and use it in GitHub Desktop.

Select an option

Save rfaisal/9297579 to your computer and use it in GitHub Desktop.
var authorization_grant = 'CAAHn34BO0R0BABtJyxdrZCQzakdmgJZBoQa0U...'; //saved from previous step
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
Ti.API.info('access_token: '+JSON.parse(this.responseText).authenticationToken); // save this for requesting protected resource
};
xhr.onerror= function() {
Ti.API.info('Auth Failure response: '+this.responseText);
};
xhr.open('POST', 'https://my_resource_auth_server.azure-mobile.net/login/facebook');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send({
"access_token" : authorization_grant
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment