Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh access_token in OAuth 2.0 in salesforce

I am developing a salesforce app and using OAuth 2.0 to login. I have a refresh token; how do I get a new access_token by sending a request to salesforce via OAuth 2.0 containing the refresh token for a particular user?

like image 610
Bhushan Lodha Avatar asked Feb 29 '12 12:02

Bhushan Lodha


People also ask

How do I get the refresh token in OAuth2 Salesforce?

Request an Updated Access Token. A connected app can use the refresh token to get a new access token by sending one of the following refresh token POST requests to the Salesforce token endpoint. The connected app can send the client_id and client_secret in the body of the refresh token POST request, as shown here.

How do I refresh an expired access token?

For example, once an access token expires, the client application could prompt the user to log in again to get a new access token. Alternatively, the authorization server could issue a refresh token to the client application that lets it replace an expired access token with a new one.

How do you refresh OAuth?

To use the refresh token, make a POST request to the service's token endpoint with grant_type=refresh_token , and include the refresh token as well as the client credentials if required.


1 Answers

Taken from "Digging Deeper into Oauth 2.0 on Force.com", your application can obtain a new access token by POSTing another request to: https://login.salesforce.com/services/oauth2/token. The payload should be of the form: grant_type=refresh_token&client_id=[your client id]&client_secret=[your client secret]&refresh_token=[the user's refresh token].

like image 159
dotNetkow Avatar answered Oct 02 '22 23:10

dotNetkow