Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

katec3's avatar
katec3
Explorer | Level 3
5 years ago
Solved

Short lived access token on new account - serverless function

I have a serverless function that accesses a Dropbox app folder using the access token generated in the app console to downloads files. It is triggered through a push notification from Dropbox. This happens in the background with no user interaction. I have been developing using my own Dropbox account and have had no problem with the token expiring. I've now switched to a different gmail email address used by the project I'm developing for and created an app in the same way. This time I get a token prefixed with 'sl' that expires. I've followed the instructions here: https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Tokens-only-valid-for-4-hours-from-app-console/m-p/425358/highlight/true#M22718 But still get an 'sl' prefixed token that expires. Please can anyone advise why I'm getting different types of tokens between the 2 accounts and how to get a long life token? Alternatively, is there any way to refresh a token through a serverless function. Many thanks.

  • You can get a refresh token via the OAuth app authorization flow and store and re-use that server-side without any further manual user interaction if you wish. 

     

    As for the short-lived access token you're getting, it sounds like you may be using the "Generate" button. That only enables you to easily get access tokens, not refresh tokens. If you do want a long-lived access token from that, you'd need to set the "Access token expiration" setting to "No expiration" before generating the access token.

     

    In any case, I recommend first reading the OAuth Guide and authorization documentation for reference first to see how these work. If something then isn't working as expected, please post here to show the part that isn't working and we'll be happy to take a look. For instance, post the code and unexpected output, etc. Don't post any access/refresh tokens or app secrets themselves though.

2 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    5 years ago

    You can get a refresh token via the OAuth app authorization flow and store and re-use that server-side without any further manual user interaction if you wish. 

     

    As for the short-lived access token you're getting, it sounds like you may be using the "Generate" button. That only enables you to easily get access tokens, not refresh tokens. If you do want a long-lived access token from that, you'd need to set the "Access token expiration" setting to "No expiration" before generating the access token.

     

    In any case, I recommend first reading the OAuth Guide and authorization documentation for reference first to see how these work. If something then isn't working as expected, please post here to show the part that isn't working and we'll be happy to take a look. For instance, post the code and unexpected output, etc. Don't post any access/refresh tokens or app secrets themselves though.

About Dropbox API Support & Feedback

Node avatar for 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!