cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

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

Support the old drobox and the new under same application

Support the old drobox and the new under same application

Omri1984
Explorer | Level 4
Go to solution

Hi guys,

my app is trying to support the old drobox and the new under then same client .

 

after getting the auth tokens we are creating a  

new DropboxTeamClient(request.AccessToken);

 

then when we want to call the new client we use this 

var account = await client.AsMember(request.AsMember).Users.GetCurrentAccountAsync();
var spaceclient = client.AsMember(request.AsMember).WithPathRoot(new PathRoot.Root(account.RootInfo.RootNamespaceId));

 

 

no you told me before that the refresh token for the .NET SDK is refreshing the toke automatically.

but after few hours i got an exception that my token is expired.

 

can you help me understand what do I need to do?

i will say that while i am using specific client i am using in during all the process ?

 

 

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

@Omri1984 Здравко is correct; the SDK can handle the refresh process for you automatically, but you need to supply the refresh token, and app key, and if not using PKCE, the app secret. In your code, you're only supplying an access token.

 

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).

View solution in original post

4 Replies 4

Здравко
Legendary | Level 20
Go to solution

Hi @Omri1984,

Yes, when refresh token is in use (as a client constructor argument), the client automatically refresh access token whenever needed. In your code no any refresh token can be seen. 🤔 (or I'm missing something) Just do what you are saying. 😉 Follow the your own "answer".

Good luck.

Greg-DB
Dropbox Staff
Go to solution

@Omri1984 Здравко is correct; the SDK can handle the refresh process for you automatically, but you need to supply the refresh token, and app key, and if not using PKCE, the app secret. In your code, you're only supplying an access token.

 

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).

Omri1984
Explorer | Level 4
Go to solution

Omri1984_0-1662727382357.png

i am using the NET SDK soafter open a different ticket i asked if i will need to refresh the token and the answer i got is above,

 

so i need to call the method anyway just in case the token should be refreshed?

 

 

 

like this 

 

new DropboxTeamClient(request.AccessToken);

 

var account = await client.AsMember(request.AsMember).Users.GetCurrentAccountAsync();
var spaceclient = client.AsMember(request.AsMember).WithPathRoot(new PathRoot.Root(account.RootInfo.RootNamespaceId));

client.RefreshAccessToken(null);

 

 

or need to call the refresh token if an AUTH exception is thrown or do I need to do it before every request?

Greg-DB
Dropbox Staff
Go to solution

@Omri1984 It looks like our comments just crossed. Please refer to my previous comment for information. If you configure that as described there, you do not need to call RefreshAccessToken yourself.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Omri1984 Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?