One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
Ivan_
2 years agoHelpful | Level 6
Generate Long-live access token for Oauth
Hi, I need to implement long-live token generation via c# code
I found this reference https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/OAuthPKCE/Program.cs
Unfo...
Greg-DB
Dropbox Staff
2 years agoYes, the Dropbox API and .NET SDK do support refresh tokens.
That sample requests "offline" access to get a refresh token in this line, the refresh token is received here, and the refresh token is used to make a client here. The client will perform the refresh process using the supplied refresh token automatically.
Ivan_
2 years agoHelpful | Level 6
- Greg-DB2 years ago
Dropbox Staff
There are a number of scenarios that can cause the refresh to fail like this, such as:
- missing/incorrect/malformed refresh token
- revoked refresh token (e.g., when the user unlinks the app via https://www.dropbox.com/account/connected_apps , etc.)
- missing/incorrect/malformed app key
- incorrect/malformed app secret
- missing app secret (if the refresh token was retrieved using the non-PKCE flow)
Check and make sure you're supplying the correct values when building the DropboxClient. If you're supplying any incorrect value(s), update your app to supply the correct value(s). If the refresh token has been revoked, you'll need to have the user re-authorize the app to access the account to receive a new valid refresh token.
The response body on that 400 error response may contain a more specific error message, though the .NET SDK unfortunately does not currently expose that. There's an open request to update it to do so. You can perform the call manually to check for an error message in the response body however, e.g., using curl like this:
curl https://api.dropboxapi.com/oauth2/token \ -d refresh_token=REFRESHTOKENHERE \ -d grant_type=refresh_token \ -d client_id=APPKEYHERE
By the way, you do not need to check for 'expired_access_token' yourself like that. As long as you provide correct credentials to the DropboxClient, it will catch and handle that error for you automatically.
I recommend running the sample code first to see how it works first.
- Ivan_2 years agoHelpful | Level 6
Now I receive such error
I double-checked client id, everything is right
- Greg-DB2 years ago
Dropbox Staff
There are a number of different things that can cause that error. Did you check everything listed in my previous message?
Have you tried running the example code without modification first?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,953 PostsLatest Activity: 7 hours ago
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!