cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Re: UWP Webview and Token Authorization

UWP Webview and Token Authorization

nashworth
Helpful | Level 5

Since Dropbox has decided to nix support for Edge 18, which has made the UWP Webview control useless for authorization to get a token, is there a workable solution for UWP?

 

I have not found a way for a UWP app to launch the external browser, perform the OAuth2 flow, and then listen for the redirect URL in response to retrieve the token. I have examined this page, but it applies to WPF desktop apps or ASP web apps and the HttpListener does not work in UWP without special permissions or command lines:

 

https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_DropboxOAuth2Helper.htm

 

Is there ANY workable solution for a UWP app to authorize a user to get a token to upload/download files to Dropbox storage from a UWP app that works out of the box?

 

More information regarding the issues with Webview and Edge 18 I found here which confirms multiple users are being affected:

 

https://www.dropboxforum.com/t5/Dropbox-installs-integrations/Upgrade-your-browser-to-use-Dropbox/m-...

11 Replies 11

Semaphore
Helpful | Level 6

I also experience this problem. The problem is that I cannot update webview until MS will release all the features I need in WinUI 3.0.

dropbox.png

nashworth
Helpful | Level 5

Exact same problem, same error message about "Upgrade your browser". Was working fine last week or just before Dropbox made the change. 

Greg-DB
Dropbox Staff

It sounds like the web view unfortunately doesn't use a recent/supported browser engine even when the latest Edge is installed. Using web views isn't officially supported for the OAuth flow though anyway, so the flow should be sent through the system browser regardless.

 

If you can't run a listener to handle the redirect URI in UWP, one solution may be to send the PKCE OAuth flow through the system browser, with a custom URL scheme registered in your app used as the redirect URI to receive the result.

 

The API v2 .NET SDK doesn't have a sample like this for UWP, but I'll pass this along as a feature request for the team to write and share one. I can't promise if/when that might be done though. 

nashworth
Helpful | Level 5

Thank you, I will look into that option. The existing samples provide a blueprint for how it should work. 

 

Documentation on creating a uri scheme for UWP app to handle redirect:

 

https://docs.microsoft.com/en-us/windows/uwp/launch-resume/handle-uri-activation

 

Semaphore
Helpful | Level 6
Hello Greg, it's not an option. You've broken many uwp apps (end users are frustrated) and waiting a month while you prepare sample and we rewrite our apps, build them, publish and pass certification is not what people are waiting for. Other cloud providers like google and onedrive still work fine and end users are forced to switch to them. Is that a recommended solution to a problem? Obsoleting edge 18 was premature and unjustified choise and needed to be unrolled in expedite way.

Semaphore
Helpful | Level 6
In the worst case you can offer another button "proceed anyway". I don't believe edge 18 won't be able to display two buttons and several textboxes.

Greg-DB
Dropbox Staff

@nashworth Thanks for sharing that link!

 

@Semaphore Thanks for the feedback! I'll pass it along to the team to see if we can get that working again. I can't make any promises myself though as web views weren't officially supported for this, and the app authorization page is part of the Dropbox web site and so subject to its system requirements. I'll follow up here once I have an updates on that.

 

Given that, whether or not the team is able to make this work in the web view again, I highly recommend updating your app to use the system browser as documented. It looks like launching the URI as shown here in Microsoft's documentation, and handling the result via a custom URL scheme as shown here in their documentation would be a good solution going forward.

Andrey K.1
Helpful | Level 5

Hi Greg!

If you highly recommend updating our app to use the system browser as documented, is it possible to get simple sample how to do this in UWP? 

I need ANY help. I spent many days for trying to get help from your documentation, wrote two tickets, but couldn't find working docs for UWP.

Since October our customers couldn't use our app for connecting to their data in Dropbox.

 

And, please, remove samples for universalDemo from https://www.dropbox.com/developers/documentation/dotnet

It's completely useless for UWP now.

Greg-DB
Dropbox Staff

@Andrey K.1 Thanks for the feedback! I've sent this to the team to get the examples updated, but I can't offer a timeline for that.

 

It seems that using a custom URL scheme with the PKCE flow works though. I don't have an official example to offer, but while I'm not a UWP programmer myself, it looks like the necessary pieces work in my testing. For instance:

 

First, I define a redirect URI using a custom URI scheme:

private readonly Uri RedirectUri = new Uri("customappurl://redirect_receiver/");

The "customappurl" is just an example. You should use something unique and specific to your app instead. The "redirect_receiver" can also be whatever you want.

 

Then I register that custom URI scheme in the UWP app as covered in Microsoft's 'Handle URI activation' documentation, and the redirect URI for the Dropbox API app on the Dropbox App Console.

 

Then I can configure the PKCE flow otherwise as shown in the existing example and get the authorization URL and launch that authorization URL in the system browser as shown in the Microsoft 'Launch the default app for a URI' documentation:

var OAuthFlow = new PKCEOAuthFlow();
var authorizeUri = OAuthFlow.GetAuthorizeUri(OAuthResponseType.Code, ApiKey, RedirectUri.ToString(), state: state, tokenAccessType: TokenAccessType.Offline, scopeList: scopeList, includeGrantedScopes: includeGrantedScopes);

var success = await Windows.System.Launcher.LaunchUriAsync(authorizeUri);
if (success)
{
    // URI launched
    System.Diagnostics.Debug.WriteLine("Launching authorize URI succeeded.");
}
else
{
    // URI launch failed
    System.Diagnostics.Debug.WriteLine("Launching authorize URI failed.");
}

 

That opens the authorization page in the system browser, and after the user authorizes the app, I can receive the resulting redirected URI as eventArgs.Uri in OnActivated per the Microsoft 'Handle URI activation' documentation. That should be passed to ProcessCodeFlowAsync like redirectUri is in the existing example.

 

Hope this helps! 

Need more support?