cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Re: legacy tooken

legacy token

bspindia
Helpful | Level 7
Go to solution

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

21 Replies 21

bspindia
Helpful | Level 7
Go to solution

ok used location.assign()

and got code in redirected url

used url searchparamaters and stored code

but got 400 error as Unexpected response_type request param value.

Š—Š“рŠ°Š²ŠŗŠ¾
Legendary | Level 20
Go to solution

@bspindia wrote:

...

again i made a location.assign("
...

Why "again"?! šŸ¤” You have already all you can get from this page (i.e. the code). What are you looking for there again? šŸ§

 


@bspindia wrote:
...
but got 400 error as Unexpected response_type request param value.

Yes, it's normal. You haven't set 'response_type' parameter - a mandatory parameter! Here the error message can be a bit more clear (i.e. something like "missing request param", not "unexpected"), but...

bspindia
Helpful | Level 7
Go to solution

means i have to make fetch with received code for token, right

Š—Š“рŠ°Š²ŠŗŠ¾
Legendary | Level 20
Go to solution

@bspindia wrote:

means i have to make fetch with received code for token, right


Did you read the documentation? What is the call /oauth2/token, you asked about previously for? šŸ˜‰

Also, take in mind the above call is used in different situations, with different params (different results, of course) - when you are getting your refresh token and when you are using this token (to get refreshed access token)! Don't forget what are you doing in any particular situation (forgetting means error).

bspindia
Helpful | Level 7
Go to solution

i compress the input file image to webp using canvas,

and uploaded using token

now due to short live tokens, i am getting unauthorised error while uploading blob

hence to i need unexpired token,

now as dropbox is not giveing legacy tokens,

i have to authorize app-> generate new token with code->upload blob to dropbox with token

Š—Š“рŠ°Š²ŠŗŠ¾
Legendary | Level 20
Go to solution

@bspindia, don't be so lazy! Don't ask question that I just explained in my previous post above. Ok. I'll repeat again: one of the possible usage of mentioned call is access token refresh!!! Do you need such a refresh (i.e. your access token expired as explained here, for instance)?

Greg-DB
Dropbox Staff
Go to solution

@bspindia Š—Š“рŠ°Š²ŠŗŠ¾ is correct; you can use a refresh token to get new short-lived access tokens when needed without having the user manually re-authorize the app each time. Please refer to the resources linked earlier in this thread for more information on that.

bspindia
Helpful | Level 7
Go to solution

as per my understanding,

i got the code, and when i made a curl request from terminal window received short live token and refresh token

i should keep refresh token and request for shorl live token using refresh token using curl to make api calls,

am i right 

Š—Š“рŠ°Š²ŠŗŠ¾
Legendary | Level 20
Go to solution

@bspindia wrote:

...

i should keep refresh token and request for shorl live token using refresh token using curl to make api calls,

...


Either 'curl' or 'fetch'... Yes.

bspindia
Helpful | Level 7
Go to solution

every thing is fine when run from terminal, but can you please correct paramenters, i am getting this error

{"error": "invalid_request", "error_description": "The request parameters do not match any of the supported authorization flows. Please refer to the API documentation for the correct parameters."}

 

$headers[]="Accept:application/json";$headers[]="Content-Type:application/json";
$cl = curl_init();
    curl_setopt($cl, CURLOPT_URL,'https://api.dropbox.com/oauth2/token');
    curl_setopt($cl, CURLOPT_POST,true);
    curl_setopt($cl,CURLOPT_HTTPHEADER,$headers);
    curl_setopt($cl,CURLOPT_POSTFIELDS,'{"grant_type":"refresh_token"}');
    curl_setopt($cl,CURLOPT_POSTFIELDS,'{"refresh_token":"****refresh_token_generated_from terminl******"}');
    curl_setopt($cl,CURLOPT_POSTFIELDS,'{"****my_AppKey******":"***AppSecret*******"}');
    curl_setopt($cl,CURLOPT_CONNECTTIMEOUT,2);
    curl_setopt($cl,CURLOPT_RETURNTRANSFER,true);
$clRes = curl_exec($cl);
echo $clRes;
curl_close($cl);
Need more support?