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
exports.get = function(request, response) { | |
request.user.getIdentities({ | |
success: function (identities) { | |
response.send(statusCodes.OK, {user: request.user, identities: identities}); | |
}, | |
error: function (err) { | |
response.send(statusCodes.INTERNAL_SERVER_ERROR, err); | |
} | |
}); | |
}; |
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
var async = require('async'), | |
https = require('https'), | |
querystring = require('querystring'), | |
jwt = require('../shared/jwt'); | |
exports.register = function (api) { | |
api.post('facebook', facebook); | |
}; | |
function facebook(request, response) { | |
var params = { |
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
var crypto = require('crypto'); | |
exports.createZumoJwt = function zumoJwt(masterKey, lifeTimeHrs, aud, userId, claims) { | |
function base64(input) { | |
return new Buffer(input, 'utf8').toString('base64'); | |
} | |
function urlFriendly(b64) { | |
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(new RegExp("=", "g"), ''); | |
} | |
function signature(input) { | |
var key = crypto.createHash('sha256').update(masterKey + "JWTSig").digest('binary'); |
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
exports.register = function (api) { | |
api.post('facebook', facebook); | |
}; | |
function facebook(request, response) { | |
response.send(statusCodes.OK, { message : 'Hello World!' }); | |
} |
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
{ | |
"facebook": { | |
"userId": "Facebook:67576576", | |
"accessToken": "CAAHn34BO0R0BAPRGjHhnKw4rkVwmlGI4UeSXGS..." | |
} | |
} |
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
//table name todoitem and has id, text, and complete fields | |
var access_token = 'eyJhbGciOi...'; | |
var xhr = Titanium.Network.createHTTPClient(); | |
xhr.setTimeout(30000); | |
xhr.onload=function() { | |
Ti.API.info('Response by PATCH: '+this.responseText); | |
}; | |
xhr.onerror= function() { | |
Ti.API.info('Error response: '+this.responseText); | |
}; |
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
//sending back whatever is receving as a body and parameter | |
exports.post = function(request, response) { | |
response.send(statusCodes.OK, { request_body: request.body, request_param: request.query }); | |
}; | |
exports.put = function(request, response) { | |
response.send(statusCodes.OK, { request_body: request.body, request_param: request.query }); | |
}; |
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
var https=require('https'); | |
var querystring=require('querystring'); | |
var _my_lat=37.78583526611328; | |
var _my_lng=122.40641784667969; | |
var _my_fb_access_token ='somebigvaluefromfacebook'; | |
var params = { | |
type: 'place', | |
center: _my_lat+','+_my_lng, | |
access_token: _my_fb_access_token |
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
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'); |
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
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'); |