We’re aware of an issue causing slower load times on the Dropbox Community forum. It should be resolved soon. Thanks for your patience!
Forum Discussion
Koichia
5 years agoExplorer | Level 4
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-DB5 years ago
Dropbox Community Moderator
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.
- Koichia5 years agoExplorer | Level 4
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.
- kailasbhole5 years agoNew member | Level 2
Is this functionality still not implemented
- Greg-DB5 years ago
Dropbox Community Moderator
kailasbhole No, I don't have an update on this request.
- DrMDodd4 years agoExplorer | Level 3
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-DB4 years ago
Dropbox Community Moderator
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).
- Koichia4 years agoExplorer | Level 4
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
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!