cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Whether you are transferring a single drive, a team or an entire organization, Movebot's cloud migration tool has been built to make your Dropbox migration simple - learn all about it here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Gelembjuk
Helpful | Level 5

I have got the problem with my app.

It worked fine for long time and now somethign happend. I can not understand what is wrong here.

 

The problem is with oauth2 auth process.

The first step works fine. I call https://www.dropbox.com/oauth2/authorize  with my client_id, redirect_url (it is registered in the app).

User approves access and dropbox redirects me back to the redirect_url and there is the code argument (access code).

 

When i call /oauth2/token to exchance this code for the access token , i have the http 400 error.

 

2020-11-04 08:19:43

> POST /oauth2/token HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 5.1) Chrome/23.0.1271.95 Safari/537.11
Host: api.dropboxapi.com
Accept: application/x-ms-application, image/gif, application/xaml+xml, *\/*
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Mozilla/5.0 (Windows; U; Windows NT 5.1; uk; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
Content-Length: 223

grant_type=authorization_code&code=Vwb***EU_yE&client_id=7cor***3&client_secret=******&redirect_uri=https%3A%2F%2Fdev7-roman-web1.*****.com%2Fdropbox_oauthcalback.htm

* upload completely sent off: 223 out of 223 bytes
< HTTP/1.1 400 Bad Request
< Content-Length: 11
< Content-Type: text/plain
< Date: Wed, 04 Nov 2020 08:19:10 GMT
< Server: envoy
< Connection: close
<
* Closing connection 12

Bad Request

WHat can be wrong with it? any idea?

1 Accepted Solution

Accepted Solutions

Re: Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Gelembjuk
Helpful | Level 5

Ok. Other possible reason of my problem is that there was wrong User-Agent string n the request (second line from bottom)

View solution in original post

5 Replies 5

Re: Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

UKCloud
New member | Level 2

I also have this exact problem. 

 

It seems to have occurred afer this change:

https://dropbox.tech/developers/now-available--scoped-apps-and-enhanced-permissions

but in that blog it says that existing Apps will continue to work.

DropBox this is a ig problem for those of us who have existing apps.

Re: Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Gelembjuk
Helpful | Level 5

I seems found the reason .

My endpoint to do the second step was

https://api.dropboxapi.com/oauth2/token 

when i replaced it to 

https://www.dropboxapi.com/oauth2/token

all wtarted to work fine.

 

before it worked.  maybe that endpoint support for oauth2 was canceled at some point and i didn't notice

Re: Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Gelembjuk
Helpful | Level 5

I hve read the docs. https://www.dropbox.com/developers/documentation/http/documentation

It ways the endpoint must be 

https://api.dropboxapi.com/oauth2/token

So, now i am confused.

Re: Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Gelembjuk
Helpful | Level 5

Ok. Other possible reason of my problem is that there was wrong User-Agent string n the request (second line from bottom)

Re: Dropbox oAuth2 auth process fails with 400 Bad Request when call /oauth2/token

Greg-DB
Dropboxer

This step of the OAuth flow should be accessed on https://api.dropboxapi.com/oauth2/token , not www.

 

This endpoint is working as expected for me, and it sounds like the original poster here found the issue with the request they were sending.

 

@UKCloud If you're still having trouble with this endpoint though, please share the details of the problem so we can help. Thanks!

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Gelembjuk Helpful | Level 5
  • User avatar
    UKCloud New member | Level 2
What do Dropbox user levels mean?
Need more support?