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

Ivan_'s avatar
Ivan_
Helpful | Level 6
3 years ago

Resfresh Token using c# code for Oauth2.0

Hi,

I need assisstance in Oauth2.0 usage.

After I generated token I have following properties

The moment that I do not understand is how to refresh token. Here I got ExpiredAt property that shows that this token will be expired.

Assuming that it is already expired, how I must refresh it ?

 

I checked provided samples of code

Will be correct if I make such verification for expiration of token

and if it expried I add this code ?

var client = new DropboxClient(Settings.Default.AccessToken, Settings.Default.RefreshToken, ApiKey, ApiSecret, config);await client.RefreshAccessToken(newScopes);var clientNew = new DropboxClient(Settings.Default.AccessToken, Settings.Default.RefreshToken, ApiKey, ApiSecret, config);

 

Thanks in advance

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Hi Ivan_,

    You don't have to perform any of the actions shown. Whenever such action has shown in some example, it's just to show how the refresh works (not that you have to use it)! Once you initialize/construct a client object using the credentials provided, the object itself will take care to refresh whenever needed. 😉 You don't need to do anything explicitly by yourself (other than just properly construct client object, together with the refresh token, and use it).

    Hope this clarifies matter.

    • Ivan_'s avatar
      Ivan_
      Helpful | Level 6

      Hi Здравко 

      Thank you for the quick response

      Can you suggest how properly construct client object with refresh token ?

      Currently I transfer only access token and it works

       

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        Ivan_ wrote:

        ...

        Currently I transfer only access token and it works


        🤓 Really?! If it works, what actually you are asking for?! 🧐😁

        You cannot expect when object is initialized with just access token it be able refresh somehow. 🤷 How such thing can happen? Impossible of course - the refresh token is required, at least! Even more, once refresh token is provided, the access token and expiration date become optional. Take a look here for instance. 😉 Depending on how exactly you have performed authentication flow (PKCE or not), you may need to add the application secret too.

        Hope this helps.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,917 PostsLatest Activity: 11 days ago
334 Following

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 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!