cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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

Здравко
Legendary | Level 20
Go to solution

@bspindia wrote:
...
    curl_setopt($cl,CURLOPT_POSTFIELDS,'{"****my_AppKey******":"***AppSecret*******"}');
...

What's this? :thinking_face: Why it's here? Authentication passes through BASIC authentication or passed as a independent parameter(s) (what's this post parameter that you are posting above actually 🧐). Can you point exact parameter matching in the description?

bspindia
Helpful | Level 7
Go to solution
Hurray made it
 
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.dropbox.com/oauth2/token');
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);
Need more support?