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

Forum Discussion

Kruno's avatar
Kruno
New member | Level 2
4 years ago

Re: Preparing my App for long-lived tokens deprecation

Hi Greg

Im using the long-live token for my simple Firmware-Updater app, but I have to switch the App from my development account to the company-account. The problem is that I can not get the long living access-token for the new App key anymore.

My software (C#) uses simplest scenario: it connects with the dropbox-app and read the files, without user interaction. It is a single user app (credentials in the app). With long-living tokens, it worked like a charm, but now I'm facing problems I can not solve.
I have readed the OAuth2 documentation, and looked the C# examples (https://github.com/dropbox/dropbox-sdk-dotnet/tree/master/dropbox-sdk-dotnet/Examples), but can not follow them to connect to dropbox. Not only that those are very complicated, but there is  also an AccessToken and RefreshToken needed. 
Please help me.

2 Replies

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

    Yes, as you found, Dropbox is phasing out the ability to create new long-lived access tokens. You can find more information on this migration here.

    Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation. Refresh tokens can be used to maintain long-term access though, and do not expire by themselves (though they can be revoked on demand, like long-lived access tokens). 

    For reference, while the creation of new long-lived access tokens is now deprecated, we don't currently have a plan to disable existing long-lived access tokens. (If that changes, we will of course announce that ahead of time.) That being the case, you can continue using existing long-lived access token(s) without interruption, if you have any. Also, note though that after the change you won't be able to create new long-lived access tokens.

    While the change began on September 30th 2021, we're releasing it gradually, so you may not have seen your app(s) affected until now. Once it applies to your app, it would apply regardless of the "Access token expiration" setting for your app, and that setting may no longer be available for your app.

    If you're using the official Dropbox API v2 .NET SDK, you can find an example of getting and using a refresh token in the OauthBasic example (non-PKCE, meant for server-side apps) as well as in the OAuthPKCE example (PKCE, meant for client-side apps). The SDK will handle the refresh process for you automatically as long as you supply the credentials as shown in the examples. If something with that isn't work as expected though, please share the details, such as the code you're using, steps you're following, and error you're getting, and we'll take a look. Please don't share any access token, refresh token, or app secret though.

  • Kruno's avatar
    Kruno
    New member | Level 2
    4 years ago

    I finally managed to connect with short-lived AccessToken properly with Oauth.

    How-To:

    1. First, You have to get a RefrehToken.  AccessToken is accessible on the AppConsole, but DropBox does not expose the RefreshToken in the Web-Interface.
      Download the API-project https://github.com/dropbox/dropbox-sdk-dotnet and open the Solution.
      Set the proper ApiKey and ApiSecret in the OauthTest/Program.cs:
       private const string ApiKey = "l430rbqrzl18xxx";
       private const string ApiSecret = "wo1yvz4xopvuxxx";
      In the AppConsole add the Redirect-Uri:  "http://127.0.0.1:52475/authorize" to your App.
      Start the OauthTest, say Yes to reset data question, let the app add itself to the db-App. If everything goes well, You will get the RefrehToken printed. Copy the RefreshToken and the AccessToken from the console and add it into your class.

    2. In your project create DropboxClient instance with:
       var config=new DropboxClientConfig();
       dBoxClient= new DropboxClient(accessToken, refreshToken, ApiKey, ApiSecret, config);

    Accessing the files is like in the Tutorial: https://www.dropbox.com/developers/documentation/dotnet#tutorial

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!