You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
bspindia
2 years agoHelpful | Level 7
legacy token
my token is expiring while making api calls and getting unauthorised error due to short live tokens, how to generate unexpired token
please assist
regards,
Sikandar
- 2 years agoHurray made it$ch = curl_init();curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=refresh_token&refresh_token=***refreshtoken******");curl_setopt($ch, CURLOPT_USERPWD, '**AppKey' . ':' . '***AppSecret*****');$headers = array();$headers[] = 'Content-Type: application/x-www-form-urlencoded';curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);$result = curl_exec($ch);echo $result;if (curl_errno($ch)) {echo 'Error:' . curl_error($ch);}curl_close($ch);
Rich
Super User II
bspindia wrote:
my token is expiring while making api calls and getting unauthorised error due to short live tokens, how to generate unexpired token
Long-lived (non-expiring) tokens can no longer be generated. They were deprecated and later replaced with short-lived and refresh tokens. A refresh token is used to automatically renew access as needed.
bspindia
2 years agoHelpful | Level 7
how to generate short live tokens using fetch api
- Greg-DB2 years agoDropbox Staff
bspindia Apps can get long-term access by requesting "offline" access, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation. I don't have a sample for this with fetch in particular, but there's a basic outline of processing this flow in this blog post which may serve as a useful example so you can translate it to fetch.
- bspindia2 years agoHelpful | Level 7i am trying to take code in res please correct headers, right now i am having error as invalid_request"Content-Type":"application/json","Authorization":"Bearer "+dropBox.apiKey+":"+dropBox.keySecret,}}).then(req=>req.json()).then(res=>console.log(res)).catch(error=>console.log(error))
- Здравко2 years agoLegendary | Level 20
Hi bspindia,
The call /oauth2/token doesn't support Bearer authorization. It's used to receive such a token, not to use it. Can be used Basic authorization to pass application key and secret or pass them as parameters. Depending on exact step you are performing other parameters should be passed too, but you are skipping them in your code. Take a look on the documentation.
Hope this sheds some light.
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 7 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!