Pages

Monday, September 23, 2019

Box API : How to Regenerate Access Token from Refresh Token

Box and Salesforce can be integrated to store files on box and link them with salesforce records. You can also write apex script to extract files or attachments from Salesforce and upload it into box folder.

For basic understanding on how to generate access token from box, refer below URL:
Box and Salesforce Integration

Whenever we perform handshake with box using OAuth, box returns access token along with refresh token. Below is sample JSON response for access token:

{
"access_token": "h91xxxxxxxxxxxxxxxxxxxx8",
"expires_in": 4012,
"restricted_to": [],
"refresh_token": "bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxM",
"token_type": "bearer"
}

here expires_in specifies the duration for which this access token is valid. After this duration, user will recieve 401 error so we need to regenerate the access token using refresh token.

Below is apex code which can be used to regenerate new access token and refresh token. In order to regenerate you need clientid, client secret and refresh token.

Above mentioned code is self explainatory.


Hope this help!!!


6 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. I agree with a lot of the points you made in this article. If you are looking for the Google Search Api, then visit SERP House. I love your content, they are very nice and very useful to us and this text is worth everyone’s attention.

    ReplyDelete
  3. Once Coinbase successfully linked to your account, click the link of the Sell/Buy Bitcoin. The link will direct you to the Buy area so simply enter the amount of Bitcoin that you need, tick on your bank account, and choose "buy Bitcoin". bitcoin mixer

    ReplyDelete
  4. Dear, you can use this site https://www.masterpapers.com/ where all the written work is done. Any difficulty, and most importantly, that your work will be appreciated, and you will be satisfied, and you will not spend a lot of money

    ReplyDelete