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

Forum Discussion

Koichia's avatar
Koichia
Explorer | Level 4
6 years ago

Can I get current access token from DropboxClient (.NET SDK)?

Hello,

 

I'm currently in the process of migrating to the short-lived access token now, and I have one question regarding access token.

 

Looking at the documentation, Dropbox.Api.DropboxClient will automatically refresh the access token if necessary.

 

My question: Can I access to the current (whether it's refreshed or not) access token and it's expiration through Dropbox.Api.DropboxClient (or somewhere else)?

 

I want to get the latest access token whenever possible because our end-user can access Dropbox resources in quick succession from their Web browser, and when they do, we make requests to their Dropbox resources from our .NET server.

 

Without the current access token available to us, the Dropbox.Api.DropboxClient will end up obtaining a new access token for almost every single request we make to Dropbox, which is not ideal for us (extra overhead, and we might get rate limitted too), and probably for Dropbox too.

 

Please let me know if it's possible for me to access the current access token (you don't have to tell me whether it's refreshed or not, since I can tell that by comparing with the old access token I have), and it's expiration from your .NET SDK.

 

Thanks!

 

 

 

 

 

7 Replies

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

    Thanks for writing this up and sharing the context. Unfortunately, no, I don't believe the Dropbox .NET SDK offers a way to retrieve the current short-lived access token like this, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

  • Koichia's avatar
    Koichia
    Explorer | Level 4
    6 years ago

    Thanks for your reply!  Yes I understand you cannot promiss if or when, but since there's still time left until the long-lived access token is retired, I'll patiently wait with a hope for this feature in the near future :)  Otherwise we'll probably make a separate call to the token endpoint on our own and get new access token manually.

  • DrMDodd's avatar
    DrMDodd
    Explorer | Level 3
    4 years ago

    I would like to know how we can get the dropbox token using the .NET SDK?  Is it true that the Refresh Token does not Expire?

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

    DrMDodd For the official Dropbox API v2 .NET SDK in C#, 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). As noted earlier in this thread, the SDK does not offer the ability to extract the current short-lived access token, but if you use the SDK as shown it will handle the access token for you.

     

    And yes, Dropbox refresh tokens do not expire automatically (though they can be revoked on demand).

  • Koichia's avatar
    Koichia
    Explorer | Level 4
    4 years ago

    As for retrieving the short-lived access token, what I do for now as a workaround is to use C# reflection (like Type.GetField() and Type.GetProperties()).

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with 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!