box api - Box Api v2 java - How to reuse the access-token within 3600 secs -


i using box api v2 (java) integrating webapp box.com.

i forward user authorize url

https://www.box.com/api/oauth2/authorize?response_type=code&client_id=client-id 

..and receive 'code' @ redirect end-point. using code, able access_token , refresh_token. know access_token valid 1 hr.

but can re-use access_token within 3600 sec period? eg:a user comes within 30 minutes , tries fetch/put files

in scenario, need create new boxclient. recommended method of client authentication using existing access token?

if answerer can paste code snippets using box java api, quite helpful.

or refreshing new access_token , refresh_token, method available?

boxclient client = new boxclient(my_client_id, my_client_secret);boxoauthmanager mgr  = client.getoauthmanager();   // refresh boxoauthrequestobject requestobject = boxoauthrequestobject.refreshoauthrequestobject(refresh_token, my_client_id, my_client_secret); boxoauthtoken newtoken = mgr.refreshoauth(requestobject); client.authenticate(newtoken); 

yes, can re-use access token within 3600-second period. common pattern web applications store access_token , refresh_token (and optionally expiration datetimes) in database record associated user.

what recommended method of client authentication using existing access token?

you'll use same authentication method when first acquired access token. don't have special reuse it. if access_token expired, determined either expiration timestamp comparison or 401 response, can use refresh_token new token pair. refreshing , persisting token pair in manner can keep user authenticated indefinitely.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -