cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out 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: 

Re: The API key I created yesterday has expired today

The API key I created yesterday has expired today

cankayaalperen
Explorer | Level 4

Hello everyone.
Yesterday I created an API key to use in my Python bot. I also made this bot run every day with Cron Job, but when I looked at the logs today, I saw that the API key has expired. I wonder if the API key needs to be regenerated every day? log output:
[2024-08-29 05:34:42.655247] - ERROR: Error uploading test.sql: AuthError('01cb395d8587418fb208c33f43828d73', AuthError('expired_access_token', None))
[2024-08-29 05:34:42.827377] - ERROR: Error uploading test.csv: AuthError('2029cd6ed2ac4dcf891f6fc3f3582763', AuthError('expired_access_token', None))

As another question; The files I created with my API key are uploaded to a folder with my name in Dropbox. My manager who invited me to the team cannot see these files. Even if I give permission, he only has permission to view, not edit. How can we solve this problem?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff

@cankayaalperen An 'expired_access_token' error indicates that the call failed because it was made with a short-lived access token that has expired. In addition to the post that Здравко linked to, you can find more information on how this works in the following resources:

As for your uploads going to the folder with your name, it sounds like you're referring to your member folder. By default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space". That means that by default, the contents of the team space will not be found, and uploads will go to your member folder.

 

You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space, if needed/desired. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

View solution in original post

6 Replies 6

Здравко
Legendary | Level 20

Hi @cankayaalperen,

Take a look here. I hope you can understand why your token expires and how to fix it. 😉

Good luck.

cankayaalperen
Explorer | Level 4

Thank you!

Greg-DB
Dropbox Staff

@cankayaalperen An 'expired_access_token' error indicates that the call failed because it was made with a short-lived access token that has expired. In addition to the post that Здравко linked to, you can find more information on how this works in the following resources:

As for your uploads going to the folder with your name, it sounds like you're referring to your member folder. By default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space". That means that by default, the contents of the team space will not be found, and uploads will go to your member folder.

 

You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space, if needed/desired. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

cankayaalperen
Explorer | Level 4
Go to solution

Greg hi! In answer to the 2nd question I asked, you told me that I need to set the “Dropbox-API-Path-Root” header, but I didn't understand the document you sent, can you give me more detailed information about this?

Greg-DB
Dropbox Staff
Go to solution

@cankayaalperen Could you elaborate on what specifically you're stuck on?

 

For example though, using the Python SDK, uploading a file like this would by default go to the member folder:

res = dbx.files_upload(f=data, path="/some folder/file.ext")

but if you instead wanted to upload into a team folder inside the team space for the account, you would do something like this:

root_namespace_id = dbx.users_get_current_account().root_info.root_namespace_id
dbx = dbx.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))

res = dbx.files_upload(f=data, path="/team folder/file.ext")

cankayaalperen
Explorer | Level 4
Go to solution
Thanks Greg, I get the point now.
Need more support?