Learn how to make the most out of the Dropbox Community here 💙!

Forum Discussion

emretezisci's avatar
emretezisci
Explorer | Level 3
2 years ago

"error_description": "missing required field \"grant_type\""

I am trying to get a sl access token with my refresh token but it gives this error. Any idea why? 
Input:

 

 

{
"body": {
"grant_type": "",
"refresh_token": "<token>"
},
"contentType": "application/json",
"followRedirect": false,
"headers": [
{
"key": "Authorization",
"value": "Basic <key>"
}
],
"method": "POST",
"timeoutSeconds": 5,
"url": "https://api.dropbox.com/oauth2/token"
}

​

 

 

Output:

 

 

{
  "error": {
    "canCatch": true,
    "canRetry": true,
    "cause": "invalid response status code",
    "description": "The HTTP request failed",
    "error": "Flow.Step.HTTPRequest.Failed",
    "metadata": {
      "body": {
        "error": "unsupported_grant_type",
        "error_description": "missing required field \"grant_type\""
      },
      "headers": {
        "Accept-Encoding": [
          "identity,gzip"
        ],
        "Content-Length": [
          "97"
        ],
        "Content-Security-Policy": [
          "sandbox allow-forms allow-scripts"
        ],
        "Content-Type": [
          "application/json"
        ],
        "Date": [
          "Tue, 07 Nov 2023 11:58:41 GMT"
        ],
        "Server": [
          "envoy"
        ],
        "X-Dropbox-Request-Id": [
          "6857e5f3655547459b471405aef54adc"
        ],
        "X-Dropbox-Response-Origin": [
          "far_remote"
        ]
      },
      "statusCode": 400,
      "statusText": "Bad Request"
    }
  }
}

 

 

 
  • trailtech's avatar
    trailtech
    New member | Level 1

    Greg-DBHi, I encountered the same problem despite using the x-www-form-url encoded. I'm using ESP32 MCU to get the token. 

    My config for the HTTP is as follows:

    The error output is as follows:


    Is there any wrong config on the HTTP?

    Thanks!

    • DB-Des's avatar
      DB-Des
      Icon for Dropbox Engineer rankDropbox Engineer

      Hi trailtech,

      We are not familiar with the esp_http_client component, but based on the error you are receiving from the API it's most likely the payload is not being formed correctly. Would it be possible for you to add logging that would allow you to visualize the full request payload before it is being sent to the Dropbox API?

      • trailtech's avatar
        trailtech
        New member | Level 1

        Unfortunately, they don't have the API to print the HTTP request. So, you suspect the payload isn't constructed properly, specifically on the "grant_type" field, right?

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Hi emretezisci,

    Haha..😁 Ok, Yes, a little confusing message, maybe. Don't catch to the words. What grant type you are declaring in fact? 🧐 Nothing? 🤔 🙃 It's something required, cannot be nothing. 😉

    Hope this gives direction.

    • emretezisci's avatar
      emretezisci
      Explorer | Level 3

      Oh I think it was deducted for some reason. 

      {
        "body": {
          "grant_type": "refresh_token",
          "refresh_token": "<token>"
        },
        "contentType": "application/json",
        "followRedirect": false,
        "headers": [
          {
            "key": "Authorization",
            "value": "Basic <key>"
          }
        ],
        "method": "POST",
        "timeoutSeconds": 5,
        "url": "https://api.dropbox.com/oauth2/token"
      }

      I use refresh_token. 

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        In addition why are you using application/json encoding? It requires application/x-www-form-urlencoded POST parameters. 😉

         

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,972 PostsLatest Activity: 3 hours ago
366 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!