Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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);
[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
Hi there!
If you need more help you can view your support options (expected response time for a 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!