cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 here!

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox .NET SDK (Refresh Token)

Dropbox .NET SDK (Refresh Token)

Helpful | Level 5

Hi,

I found changes in OAuth2 for API, so the authorization could be done with offline access, ascuirung both Access and Refresh tokens. This part is OK, with ProcessCodeFlow method in SDK. But could not find any method to refresh access token using saved refresh token.

 

Can you please help me with this case?

 

Thanks,

 

 

Capture.PNG

 

1 Accepted Solution

Accepted Solutions

Re: Dropbox .NET SDK (Refresh Token)

Dropboxer

@GevorgMel This functionality should now be available on DropboxTeamClient as of release v5.1.0. Please update and give that a try and let us know if you run in to any issues. Thanks!

View solution in original post

19 Replies 19

Re: Dropbox .NET SDK (Refresh Token)

Dropboxer

The Dropbox .NET SDK should automatically do the refresh for you, on every client creation and API call as needed.

 

If you do want to explicitly refresh though, e.g., to get an access token with fewer scopes, you should be able to use RefreshAccessToken to do so, as shown in the example here.

 

Let us know if something isn't working as expected though.

Re: Dropbox .NET SDK (Refresh Token)

Helpful | Level 5
Thank you for the reply and link to RefreshAccessToken method. I found this method in DropboxClient. What about DropboxTeamClient, I need this client and accordingly to use access token which probably been expired. How I should handle this case?

Re: Dropbox .NET SDK (Refresh Token)

Dropboxer

I believe that's not currently implemented on DropboxTeamClient. I'll ask the team to add that there as well, but I can't promise a timeline for that. I'll follow up here once I have any update on that.

Re: Dropbox .NET SDK (Refresh Token)

Helpful | Level 5
Thank you very much for great support and I will check this thread for further updates.

Re: Dropbox .NET SDK (Refresh Token)

Dropboxer

@GevorgMel This functionality should now be available on DropboxTeamClient as of release v5.1.0. Please update and give that a try and let us know if you run in to any issues. Thanks!

View solution in original post

Re: Dropbox .NET SDK (Refresh Token)

Explorer | Level 3

I understand, the Dropbox client can automatically refresh the refresh tokens if fed with the correct access token and refresh token.

But how can I retrieve the actual new access token and refresh token, to store it, for new instances of the DropboxClient?

 

Re: Dropbox .NET SDK (Refresh Token)

Dropboxer

@OFV The Dropbox client in the SDK can and will automatically handle the refresh for you, and you shouldn't even need to access to refresh token or new access token after a refresh. The refresh token doesn't change, and the client will automatically set its new access token. And if you need another client, you can just create it like you did originally and let the client handle the refresh again if needed.

Re: Dropbox .NET SDK (Refresh Token)

Explorer | Level 3

Excellent! thanks

Re: Dropbox .NET SDK (Refresh Token)

Explorer | Level 3

Greg, I still can't get it to work for a duration longer than the access token's validity.

 

(this part works

I ask for user authentication (only once) using the DropboxOAuth2Helper.GetAuthorizeUri with OAuthResponseType.Code and TokenAccessType.Offline. 

The resulting POST http request gives me a code and DropboxOAuth2Helper.ProcessCodeFlowAsync provides me an access token and refresh token based on that code. The tokens are persisted in the DB and to be used for longer periods (months) without the user needing to re-login

 

(this part fails

The DropboxClient is instantiated with the Access_token and refresh token retrieved in the first part.

Using the DropboxClient.Files.ListFolderAsync it works for a while (a few hours after initial usser auth), but the next day it fails with "Dropbox.Api.AuthException: expired_access_token/"

It concerns an MVC webapp, and the dropboxclient is newly instantiated on every use.

 

I thought the DropboxClient would do "it's thing" using the initial access and refresh tokens.

(I am using the Official Dropbox .Net v2 SDK v5.5.0 Nuget package) 

 

 

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?