Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save rfaisal/9297739 to your computer and use it in GitHub Desktop.
var access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsI...'; //saved from previous step
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
Ti.API.info('Protected Resource: '+this.responseText);
};
xhr.onerror= function() {
Ti.API.info('Error response: '+this.responseText);
};
xhr.open('GET', 'https://my_resource_auth_server.azure-mobile.net/api/auth');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-ZUMO-AUTH", access_token); // this is the magic line
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment