In this post, I am going to briefly explain how to generate the access token and secret using OAuth (v1.0a) protocol, here I am using Xero payroll API Request URLs for generating tokens. "https://www.hurl.it/" is used to generate the above token.
Steps:
1) Before start, we need to create a Xero account (https://www.xero.com/signup/) and valid application (https://api.xero.com/Application/). Once you create app, you can get the "Consumer Key" and "Consumer Secret".
2)The next step is to obtain an Unauthorized Request Token
Go to the "https://www.hurl.it/" then select "Add Authentication" and click on "OAuth 1.0a".
In the "Destination", choose GET HTTP method and add the "https://api.xero.com/oauth/RequestToken" in the place, then add the "Consumer Key" and "Consumer Secret" which is obtained from APP, after adding click the "Launch Request" to get oauth_token and oauth_token_secret.
The response is "oauth_token=EPTYMJ7K1PHATINKHC0HI7BKWDJYUY&
oauth_token_secret=C6LBH2Y5SOMK56FMJMVAHCOIE5SIKY&
oauth_callback_confirmed=true"
3) Next, we need to obtain User Authorization, for that, we have to use oauth_token which is got above as a response.
Go to the browser and copy the following URL,
https://api.xero.com/oauth/Authorize?oauth_token=EPTYMJ7K1PHATINKHC0HI7BKWDJYUY&
scope=payroll.employees,payroll.timesheets,payroll.settings,payroll.payitems,
payroll.payruns,payroll.payschedules,payroll.worklocations,payroll.paystubs
It will ask your username and password for login to the Xero account, once you log in, it will go to another page and we need to authorise application by clicking "Authorise" button. Finally it will be getting a code, this will use for a next step.
4) This is the last step for obtaining an Access Token, again go to the "https://www.hurl.it/" and set HTTP Request Method as a POST then place the URL as "https://api.xero.com/oauth/AccessToken".
Add the "Access Token" and "Token Secret" as what we get in "step 2". In addition we need to add the parameter.
Go to "Parameters",set the name as "oauth_verifier" and value is the code which gets in the above step.
As a response, we will get the AccesToken and AccesToken Secret.
This is the Response oauth_token=RFTFTVFNYAYFIKCVKOHWGITP3BH75V&
oauth_token_secret=CQGQRCKLBBFJAE6BNBVS6KWYAODN0D&
oauth_expires_in=1800&xero_org_muid=76SaGeSCeaQdSBpBvlYYxG







Comments
Post a Comment