cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App 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: 

OAuth2 implicit grant (token flow) does not work in IE/.Net Winform WebBrowser

OAuth2 implicit grant (token flow) does not work in IE/.Net Winform WebBrowser

Daniel B.97
New member | Level 1

Currently I'm developing a .Net WinForms desktop app.

I initiate a token-based OAuth2 flow with this URL in IE11 (or to be more precise: the WebBrowser control of .Net WinForms):

https://www.dropbox.com/1/oauth2/authorize?response_type=token&client_id=<myappid>&redirect_uri=<myR...>

I can login to an account and apply accept the app request. After that I should be redirected to <myRedirectUrl>

I get two different results:

1. If <myRedirectUrl> is "http://localhost" then I get "dnserror.html" in browser. Thsi should not happen.

2. If <myRedirectUrl> is a real URL I get redirected to the page. But: since it seems to be some JavaScript.Magic to redirect, the page is "redirected/reloaded": neither DocumentCompleted event nor Navigating event is fired. Therefore I never can determine, when the redirected page is displayed in browser. For me the best woult be, if Navigating event would be fired.

What can I do to get the result by code like for other OAuth2 providers?

Regards,
Daniel

24 Replies 24

Nekobul
New member | Level 1

Steve,

Guess what? You were right. The /redirect_receiver is indeed doing something. I have just tried different redirect_uri and it worked fine.

Steve M.
Dropbox Staff

Interesting. So I guess Navigated fires too late? But you tried Navigating as well, right? It seems like that should certainly fire before JavaScript on the page is executed.

Nekobul
New member | Level 1

Steve,

Yes, I have tried Navigating. It didn't work.

Daniel B.97
New member | Level 1

Hi Ivan,

here you can find my working solution. Maybe it helps you:

https://github.com/Kyrodan/KeeAnywhere/blob/master/KeeAnywhere/OAuth2/OAuth2Form.cs

I use the Navigated-Event.

The only drawback is, that due to the "JavaScript-Magic" the Default WebBrowser is opened on Windows 7 - no problems on Windows 10 (didn't ried on Vista,8, 8.1). In my opinion the JavaScript-stuff is crappy and not very stable. But I must say, that dropbox is one of the providers that implement OAuth2-Token-Flow "usable". For many others I need to use the Non-Fragment-URL-Way to a real existing Web-Server with a possible security problem - a no-go for a Desktop App.

Regards,
Daniel

 

Nekobul
New member | Level 1

Daniel,

Thank you for sharing and starting this discussion! I have already made it work by avoiding the use of the redirect_uri provided by Dropbox. In my experience the Javascript has to be kept as simple as possible. Otherwise the WebBrowser control is not able to handle rendezvous-process properly.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Nekobul New member | Level 1
  • User avatar
    Daniel B.97 New member | Level 1
  • User avatar
    Steve M. Dropbox Staff
What do Dropbox user levels mean?