You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Orgbrat
3 years agoExplorer | Level 3
How to fix the short-lived access token issue?
I have a Desktop/Mobile Xamarin application that reads and writes to the Apps folder in a users Dropbox. It has been working fine for a long time but now that Dropbox has moved to short-lived access ...
kylea
3 years agoDropbox Staff
The latest .NET SDK has a good example of using refresh tokens in the OauthBasic example. Be sure to pass the tokenAccessType: TokenAccessType.Offline parameter when constructing your url with GetAuthorizeUri in order to get a refresh token. The refresh token can then be passed DropboxClient, which is also shown in the example.
Using refresh tokens should only be necessary if your application requires background access. For typical web applications, simply prompting the user to re-authenticate is recommended. The flow will typically auto-redirect if the user is logged in and has previously authorized the app.
This is described in more detail in our Oauth Guide.
- Orgbrat3 years agoExplorer | Level 3
Thanks for the quick reply, it is very much appreciated.
I am failing to authorize with the error "scope: must be at most 0 characters, got 97"
I modified the original code to be:
string[] scopeList = new string[5] { "files.metadata.write", "files.metadata.read", "files.content.write", "files.content.read", "account_info.read" }; this.oauth2State = Guid.NewGuid().ToString("N"); var authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Code, Constants.DropboxClientId, new Uri(Constants.DropboxRedirectUri), state: this.oauth2State, tokenAccessType: TokenAccessType.Offline, scopeList: scopeList, includeGrantedScopes: IncludeGrantedScopes.None); var webView = new WebView { Source = new UrlWebViewSource { Url = authorizeUri.AbsoluteUri } };
Update:
I went into the App Console and opened the Permissions tab. The Console ask me to Migrate my requested permissions, which I did do. Went back into the app and tried to authorize again and this time I am getting the Login page from Dropbox. Step closer maybe.
Now when it authorizes thru the Login page and transfers to my WebViewOnNavigating event it returns the following URL;
https://localhost/authorize?code=xxx-Returned-Code-xxx
At this point I make a call to:
var result = await DropboxOAuth2Helper.ProcessCodeFlowAsync(new Uri(Constants.DropboxRedirectUri), Constants.DropboxClientId, Constants.DropboxClientSecret, new Uri(Constants.DropboxRedirectUri).ToString(), this.oauth2State);
This call crashes with the error : "The redirect uri is missing expected query arguments. (Parameter 'responseUri')"
Orgbrat
- Greg-DB3 years agoDropbox Staff
After the user authorizes the app, the resulting response URI will contain the information needed for completing the process on the query portion of the URI. You need to pass that response URI into ProcessCodeFlowAsync, as the 'responseUri' parameter, to complete the flow.
This error message is indicating that the responseUri value you are passing in does not contain that information on the query portion however. In this case, that appears to be because you're passing back in the original redirect URI constant ('new Uri(Constants.DropboxRedirectUri)'), not the actual result of the authorization. You should change that to the response URI (the "https://localhost/authorize?code=xxx-Returned-Code-xxx" you mentioned.) You can find an example of that here.
By the way, I notice from your code that you're processing this in a web view. The OAuth app authorization flow should be processed in the user's system browser, not a web view. See here for more information.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,916 PostsLatest Activity: 50 minutes 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!