cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Musicians, convert your MuseScore files to PDF to play music on the go! Learn more 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: 

Error in call to API function "auth/token/from_oauth1": Bad HTTP "Content-Type" header: "application

Error in call to API function "auth/token/from_oauth1": Bad HTTP "Content-Type" header: "application

umairali
New member | Level 2

i am calling app auth api but i am receiving below error.

 

Error in call to API function "auth/token/from_oauth1": Bad HTTP "Content-Type" header: "application/json; boundary=------------------------796cea680fa095ca". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack".

 

Code

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.dropboxapi.com/2/auth/token/from_oauth1");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Basic bmF0dWdweTsdwqegzbnE1MDFs4OnFiN3F3an3p3anpkdGJzOA=='
));
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
'oauth1_token' => 'natugpy83123nq5sdf01l',
'oauth1_token_secret' => 'qb7qwjsdfzwjzdtfbs8',
));
$result = curl_exec($ch);
curl_close($ch);
1 Reply 1

Greg-DB
Dropbox Staff

[Cross-linking for reference: https://stackoverflow.com/questions/50795358/error-in-call-to-api-function-auth-token-from-oauth1-ba... ]

 

The error message is indicating that your client is sending up an unexpected Content-Type value (using a boundary), when it needs to be using one of the listed expected values.

 

This appears to be happening because you're just sending the POST fields directly. You need to sending JSON though, so you would put your CURLOPT_POSTFIELDS array inside json_encode().

 

Also, note that this endpoint is only meant for use if you already have pre-existing OAuth 1 access tokens. If you don't have pre-existing OAuth 1 access tokens, you should send the user through the normal OAuth 2 app authorization flow. You can find information on how that works in the OAuth guide here:

https://www.dropbox.com/developers/reference/oauth-guide

The documentation for the OAuth 2 app authorization flow can be found here:

https://www.dropbox.com/developers/documentation/http/documentation#authorization

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?