Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Choyce T.'s avatar
Choyce T.
New member | Level 1
9 years ago

Generated access token

Hello, for unknown reason this chunk of code is not working for me (PHP). I used the "Generated access token" button to get me one.

$headers = array();
$headers[] = "Authorization: Bearer IFwO9iV...";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "https://api.dropbox.com/1/account/info");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$out = curl_exec($ch);

I always get this output: HTTP/1.1 400 Bad Request Server: nginx Date: Wed, 06 Apr 2016 13:20:28 GMT Content-Type: application/json Transfer-Encoding: chunked Connection: keep-alive X-Dropbox-Request-Id: d72abf... {"error_description": "No auth function available for given request", "error": "invalid_request"}

Please assist.

4 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    It looks like you have the wrong curl option name for setting headers. It should be CURLOPT_HTTPHEADER instead of CURLOPT_HEADER.

  • Choyce T.'s avatar
    Choyce T.
    New member | Level 1
    9 years ago

    Hello Gregory, many thanks for your help, it worked seamlessly. If you could also look into this code, as I'm getting an "Internal Server Error" when trying to upload a file (png) from a url:

    $headers = array();
    $headers[] = 'Authorization: Bearer IFwO9iVNUF...';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_URL, 'https://api.dropbox.com/1/save_url/auto/downloaded.png');
    curl_setopt($ch, CURLOPT_POSTFIELDS, "url=\"http://2.bp.blogspot.com/-5BRZLo7rynA/UzLTXxHNO5I/AAAAAAAAAOE/43_jWGpYcNc/s1600/bmw_logo_vector_by_celinah006-d66yn5l.png\");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $out = curl_exec($ch);

    Thank you.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    It looks like the issue is that your url parameter isn't properly form URL encoded. For example it should look like this:

    curl_setopt($ch, CURLOPT_POSTFIELDS, "url=http%3A%2F%2F2.bp.blogspot.com%2F-5BRZLo7rynA%2FUzLTXxHNO5I%2FAAAAAAAAAOE%2F43_jWGpYcNc%2Fs1600%2Fbmw_logo_vector_by_celinah006-d66yn5l.png");

    We'll look into returning a better error in this case though.

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If 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, Facebook or Instagram.

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!