Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Priya M.
9 years agoExplorer | Level 4
Distinction between Oauth 2 and PHP Core API (PHP SDK)
Hi, I'm from Softaculous Ltd and we are now starting to integrate with Dropbox for Backups upload and download. I want to know the difference between your PHP Core API or PHP SDK and OAUTH 2....
- 9 years agoIf you want to use the HTTPS endpoints directly, that's possible using just curl.
Here are some basic examples using curl in PHP:
https://stackoverflow.com/documentation/dropbox-api/409/uploading-a-file/1354/uploading-a-file-via-curl-in-php#t=201702211923322665017
https://stackoverflow.com/documentation/dropbox-api/410/getting-account-information/1364/getting-space-usage-information-for-the-linked-user-via-curl-in-php#t=201702211923328624075
https://stackoverflow.com/documentation/dropbox-api/412/listing-a-folder/1370/listing-the-root-folder-via-curl-in-php-and-the-curl-extension#t=20170221192336214657
https://stackoverflow.com/documentation/dropbox-api/408/downloading-a-file/20965/downloading-a-file-with-metadata-via-curl-in-php#t=201702211923411507977
https://stackoverflow.com/documentation/dropbox-api/414/getting-a-shared-link-for-a-file-or-folder/24125/creating-a-shared-link-for-a-file-using-curl-in-php#t=201702211923392625782
To get an access token for the end user's account, you need to implement the OAuth app authorization flow. You can find information on how that works here:
https://www.dropbox.com/developers/reference/oauth-guide
The documentation for those endpoints can be found here:
https://www.dropbox.com/developers/documentation/http/documentation#authorization
Greg-DB
Dropbox Community Moderator
9 years agoThe loadFromJsonFile method is the way the PHP Core SDK loads configuration settings, and isn't itself relevant to the OAuth flow.
Regarding the actual error you're getting, it looks like you're supplying a 'code' URL parameter, but that's not expected. As seen in the code you supplied, there is a 'response_type' parameter for which the value should be 'code'.
If you need help with that, please supply the actual URL of the page for that error you're getting.
Regarding the actual error you're getting, it looks like you're supplying a 'code' URL parameter, but that's not expected. As seen in the code you supplied, there is a 'response_type' parameter for which the value should be 'code'.
If you need help with that, please supply the actual URL of the page for that error you're getting.
Priya M.
9 years agoExplorer | Level 4
Hi,
I'm also trying to generate the oauth2 access token using the oauth1 token and token secret in the following way:
function converttov2($access_token){
$cheaders = array('Authorization: Bearer <ACCESS_TOKEN>',
'Content-Type: application/json',
'Dropbox-API-Arg: {"oauth1_token":"'.$access_token['t'].'", "oauth1_token_secret":"'.$access_token['s'].'"}');
$ch = curl_init('https://api.dropboxapi.com/2/auth/token/from_oauth1');
curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo '<br />Response:';
echo $response;
echo '<br />Curl Error: '.curl_error($ch);
curl_close($ch);
}
I'm getting this as output:
Response:Error in call to API function "auth/token/from_oauth1": Invalid HTTP header "Authorization": expecting "Basic" auth
Curl Error:
Can you please tell me what I'm doing wrong here?
- Greg-DB9 years ago
Dropbox Community Moderator
If you already have an OAuth 2 access token for the user, you don't need to call /2/auth/token/from_oauth1.
If there is an OAuth 1 access token you want to upgrade though, the issue is that the /2/auth/token/from_oauth1 endpoint uses "app auth", so you shouldn't supply an OAuth 2 access token. That is, this line should be like:
$cheaders = array('Authorization: Basic <base64(APP_KEY:APP_SECRET)>',The app auth documentation has a sample.
By the way, I redacted it for you, but for the sake of security, you should disable that access token that you posted. You can do so by revoking access to the app entirely, if the access token is for your account, here:
https://www.dropbox.com/account/security
Or, you can disable just this access token using the API:
https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!