Activity › Forums › Salesforce® Discussions › How is Access Token used with REST API in Salesforce ?
Tagged: Access Control, Access Specifier, Rest API, Salesforce Customization, Salesforce Development
-
How is Access Token used with REST API in Salesforce ?
Posted by sushant on December 12, 2016 at 2:11 PMHi All,
How is Access Token used In REST API ?
Please give suggestions
Thanks
Parul replied 7 years, 7 months ago 4 Members · 3 Replies -
3 Replies
-
Hi sushant,
Access token is used for authorization purpose.
Once authenticated, every request must pass in the access_token value in the header. It cannot be passed as a request parameter.
go through https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm for detail option
Hope it may help
- [adinserter block='9']
-
Hi,
The first step in any API-based integration is getting an OAuth access token to authenticate your calls.
Using the client ID and secret call the REST Auth service to obtain an OAuth access token for authenticating your API calls. This sample call demonstrates how to POST to that resource to acquire an access token.
POST https://auth.exacttargetapis.com/v1/requestToken
Content-Type: application/json
{
“clientId”: “YOUR_CLIENT_ID”,
“clientSecret”: “YOUR_CLIENT_SECRET”
}200 OK
{
“accessToken”: “YOUR_ACCESS_TOKEN”
“expiresIn”: 3600
}The access token is returned in the accessToken property. Specify this access token to authenticate all other REST API calls via the Authorization header field with the Bearer HTTP authorization scheme.
Refresh an Access Token
Note the expiresIn property in the HTTP response to the requestToken API call. Access tokens expire one hour after they are issued. If you attempt to use an expired token, you receive a 401 Unauthorized HTTP response. If this happens, refresh your access token by calling requestToken again.Follow these considerations when using the API directly and doing your own OAuth token management.
Do not request a new access token for every API call you make—-each access token is good for an hour and is reusable. Making two API calls for every one operation is inefficient and causes throttling.
Be careful where you store your client ID and secret. Never expose this information on the client side via JavaScript or store it in a mobile application. Ensure that these credentials are stored securely in your application.Hope this helps!
-
Adding some points:
Once access token is used for authorization purpose and authenticated, every request must pass in the access_token value in the header. It cannot be passed as a request parameter.
go through https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm for detail option
Hope it may helps
Log In to reply.