You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Cyri129
5 months agoNew member | Level 2
How to use https://api.dropboxapi.com/2/files/copy_reference/save
Hello, My goal is to transfer a file to DropboxAcc1 to DropboxAcc2 with this API : https://api.dropboxapi.com/2/files/copy_reference/save $ch = curl_init();
curl_setopt($ch, CURL...
Greg-DB
5 months agoDropbox Staff
A 'no_permission' error from /2/files/copy_reference/save means:
no_permission
Void You don't have permission to save the given copy reference. Please make sure this app is same app which created the copy reference and the source user is still linked to the app.
You mentioned you're using two different apps, so it sounds like that may be the cause. You'll need to instead make sure you're using the same app for both accounts. Additionally, make sure you haven't unlinked the account used to create the copy reference.
For example, the flow should work like this:
- connect DB1app to DropboxAcc1, resulting in AccessToken1
- use AccessToken1 to call /2/files/copy_reference/get, resulting in CopyReference1
- connect DB1app (the same app as above) to DropboxAcc2, resulting in AccessToken2
- use AccessToken2 to call /2/files/copy_reference/save with CopyReference1, resulting in the file being saved to DropboxAcc2
Keep in mind that your access tokens (assuming you aren't using any "team scopes") are specific to a particular app and account pair. You can't change which app or account a particular access token is for.
Also, you can only use the "Generate" button on the app's page on the App Console to generate an access token for an app on the particular account that owns the app. You'd need to use the OAuth app authorization flow to get an access token for the same app on the other account. (You can use the OAuth app authorization flow for the app owner account as well.)
You can't directly tell which app any given access token or copy reference is for just based on the access token or copy reference, so if you've lost track of which is for which, I recommend you start over and get new access tokens and copy reference(s) using a single app.
- Cyri1295 months agoNew member | Level 2
Hello,
Thanks for the answer, can you please give me more explanations about this :
- connect DB1app (the same app as above) to DropboxAcc2, resulting in AccessToken2
How can i connect my app to 2 differents accounts programmatically :
The only way to do it is like that ? :
Log in my browser with my email password to DropboxAcc1, then use Oauth flow with this code and App1 client_id and client_secret :
$tokenUrl = 'https://api.dropboxapi.com/oauth2/token'; $tokenParams = http_build_query([ 'code' => $authorizationCode, 'grant_type' => 'authorization_code', 'client_id' => $clientId, 'client_secret' => $clientSecret, 'redirect_uri' => $redirectUri, ]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $tokenUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $tokenParams); curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, ''); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded', ]); $tokenResponse = curl_exec($ch); $tokenResponse = json_decode($tokenResponse, true); curl_close($ch);
Here i got DropboxAcc1 token and i can get copy_reference of a file on DropboxAcc1
Then :
Logout MANUALLY my browser to DropboxAcc1 and login with DropboxAcc2 informations and use again the php code above.
Now iv got a second token and can use it to save file on DropboxAcc2.
I think i can do it like that, but i need to login and logout manually and this is not what i want...
- Здравко5 months agoLegendary | Level 20
Hi Cyri129,
What you described in the last post is exactly what need to be done. 😉 It's a bit different than your initial post where you're using different applications for different accounts. Take a look and compare your posts. Can you see the difference? In other words, just use the same app key and app secret while changing only your account login.
Hope this sheds additional light.
- Cyri1295 months agoNew member | Level 2
Hello !
The problem with my last post is i need to login/out manually, if i want to use APIs its because i want things to be done programmatically.
I don't want to give my password and email to users who will use my app.
Or maybe i can refresh (programmatically) both tokens every hours with a CRON and i use refreshed tokens so i need to log in/out account only for the first access token ?
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 5 days agoIf 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!