Skip to content

Instantly share code, notes, and snippets.

@jeromyevans
Created June 10, 2015 06:36
Show Gist options
  • Save jeromyevans/c730047c0ec03cc188ee to your computer and use it in GitHub Desktop.
Save jeromyevans/c730047c0ec03cc188ee to your computer and use it in GitHub Desktop.
Request Xero Request Token
// Initiate the request to Xero to get an oAuth Request Token.
// With the token, we can send the user to Xero's authorize page
exports.requestXeroRequestToken = function(request, reply) {
oauth.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results) {
if (error) {
console.log(error);
return reply.view('failed');
}
// store the token in the session created by the hapi yar plugin
request.session.set('oauth', {
token: oauth_token,
token_secret: oauth_token_secret
});
// redirect the user to Xero's authorize url page
return reply.redirect(AUTHORIZE_URL+oauth_token);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment