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

lrduques's avatar
lrduques
Helpful | Level 6
6 years ago

OAuth2 access token request invalid - grant_type expecting \"authorization_code"\

Hi, I am trying to obtain an acces token by converting the authorization code. I followed both documentation available in the following links:  https://www.dropbox.com/developers-v1/core/docs#oa2...
  • Greg-DB's avatar
    6 years ago

    The "grant_type" parameter value should literally be the string "authorization_code", and only the "code" parameter value should be the authorization code string you received. 

    That is to say, your parameter line should like something like this instead:

        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('code'=> $_GET['code'], 'client_id' => "5n5**********aw", 'client_secret' => "zq**********tn8", 'grant_type' => "authorization_code", 'redirect_uri' => 'http://localhost/optiSurface-dropbox/login.php')));

    By the way, you linked to the old version of the documentation. For reference, the current version is here: https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token 

  • lrduques's avatar
    lrduques
    6 years ago

    Problem solved!! 

    I just realized it's not necessary to include the complete path from the URL. Since the app has permission to access just it's own folder, I just included the file path itself.

    So my json file it's like this:

    {
        "path": "/text.txt",
        "include_media_info": false,
        "include_deleted": false,
        "include_has_explicit_shared_members": false
    }

    Thank you!!

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,880 PostsLatest Activity: 3 minutes ago
325 Following

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 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!