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: 

Long life Access token or access token refresh

Long life Access token or access token refresh

Pathirny
Explorer | Level 3

Hi there,

 

I am currently working on a Next.js project where I am fetching photos from a folder in Dropbox. The photo's render fine but the issue is that after 4 hours the access token expires. I know that these are short life tokens but I was wondering if I can get a token which has a longer life? Or if there is a call I can make to refresh the access token every 4 hours?

 

Thank you

6 Replies 6

Rich
Super User II

@Pathirny wrote:

I know that these are short life tokens but I was wondering if I can get a token which has a longer life? Or if there is a call I can make to refresh the access token every 4 hours?


Long-lived access tokens are no longer available. You need to use short-lived tokens along with a refresh token.

 

Greg-DB
Dropbox Staff

@Pathirny Rich is correct. Dropbox now issues short-lived access tokens, and for long-term access you should get a refresh token. In addition to the blog post Rich linked to, be sure to also refer to the OAuth Guide and authorization documentation.

Pathirny
Explorer | Level 3

Hi Rich,

 

Thanks for the response! I'll look into this.

 

I'm currently creating a website for a client who wants a gallery of photos and trying to find an easy way for them to add photos to a folder which then get rendered on the page in Next.js.

 

Any idea if Dropbox is the best option for such functionality?

 

Thanks!

Pathirny
Explorer | Level 3

Thanks for the response Greg!

 

I'm currently creating a gallery of photos for a client in Next.js and will look into the above.

 

Thank you

Pathirny
Explorer | Level 3

Hi Greg,

 

I'm using the documentation you've shared and I keep coming across a CORS error when trying to fetch the access token.

 

I'll share the code and error below for your consideration. Please note I am using Next.js

 

Any recommendations on how I can get past CORS?

 

Pathirny_0-1724185907690.png

Pathirny_1-1724185939979.png

 

Thanks 

Greg-DB
Dropbox Staff

The https://www.dropbox.com/oauth2/authorize... URL you construct points to a web page where the user would choose whether or not to allow the app to access their account. That means the app should direct the user to that URL in their web browser. The app should not try to access the contents of that URL programmatically; for example, you should not have the app try to retrieve the contents of that URL using 'fetch'. Please refer to the links in my previous message for more information on how this process works.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Pathirny Explorer | Level 3
What do Dropbox user levels mean?