Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get non expiring Access Token from Box or Get access token from box by passing UserName and Password.?

Tags:

box-api

I got the Access Token using Box Api but it is expiring in 1 hour. What I want here is,

Either I need non expiring access token or get the access token by passing my Box User Id and Password to API.

If above things are possible let me know the way.

Thanks in advance..

like image 498
user2003167 Avatar asked Feb 01 '13 06:02

user2003167


1 Answers

You've got what is called a Bearer Token and a Refresh Token. The Bearer token is good for an hour, and the Refresh token is good for 60 days. The Refresh token can be traded in for another pair of tokens, which resets both clocks at the time you do the refresh.

Box doesn't have tokens that you can get via a username-password grant in OAuth2, because that inherently doesn't work for enterprise customers that need to do SSO through their ActiveDirectory / Okta / Ping / 2-factor / SecureID signin flows.

What you probably want is an SDK that handles the refreshing of the token for you. Most users won't ever have to logon a second time, unless they go on vacation for a few weeks. Box has already released several SDKs, all on github with open-source licenses. Most of them take care of refreshing the token for you automatically.

We've also added some enhancements recently (early 2014) to help multi-server implementations work more smoothly with the refresh-token flow, including allowing you to use the old refresh token to get the new token multiple times in a narrow time-window. That helps with both multi-threaded environments trying to get new tokens across a number of threads (or servers). It also helps with the case where you have a network interruption and you don't actually get the new token-pair back from your initial refresh call.

like image 130
Peter Avatar answered Oct 12 '22 13:10

Peter