8

I am developing a Xamarin Mac application and I need to do some data syncing with Dropbox.

I have created a WebView which navigates to a URL where the user is prompted to enter its username and password. After hitting OK and successfully signing in I am presented with a new screen where I can grant or deny the app access to it's folder in Apps > AppName inside Dropbox.

Regardless of hitting Cancel or Allow nothing happens. If I however click on the Dropbox icon on the top left I am navigated normally to my dashboard.

I thought that this might be a Javascript problem or something similar but I have changed all the properties I can think of and I am still stuck on the same page.

What I need to set to be able to move on?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ivan Crojach Karačić
  • 1,911
  • 2
  • 24
  • 44
  • I also suspect a JavaScript error. Can you check the JavaScript console in that browser to see if/what that may be? Also, in any case, what browser doe the WebView use? If it isn't officially support ( https://www.dropbox.com/help/3 ) I would recommend jumping out to the normal system browser instead. – Greg May 04 '15 at 15:11
  • I have put the task aside since I had to do some other stuff but I am now back at this and didn't get any further. Can you explain what you mean by " I would recommend jumping out to the normal system browser instead". How can I catch the interaction between the system browser and dropbox from outside my app. – Ivan Crojach Karačić May 15 '15 at 08:35
  • [Cross-linking for reference: https://www.dropboxforum.com/hc/communities/public/questions/202340919-Cocoa-WebView-not-reacting-to-Allow-button-click- ] – Greg May 15 '15 at 17:44
  • I meant that I would recommend sending the user to visit the /authorize URL in their own browser (e.g., Chrome, Firefox, IE, Safari, etc.). That way, the user is more likely to use a supported browser (per https://www.dropbox.com/help/3 ). Once the user authorizes your app, you can use an OAuth callback to notify/get back to your app. That's that `oauth_callback` parameter in OAuth 1, or the `redirect_uri` parameter in OAuth 2. – Greg May 15 '15 at 17:44

1 Answers1

4

I have found the solution for my problem which is quite a strange one (IMO) but maybe it's the default way on OSX.

I subscribed to all event's the webView control has to offer and I found this "nugget".

Once the user clicked on "Allow" the CancelClientRedirect event was raised and by chance I found out that if you check out the

YourWebViewControl.MainFrameUrl

you could see which callback URL should have been called.

It would either be http://yoururl.com/oauth=someRandomString or http://yoururl.com/not_approved=true.

Based on this URL you can then know what happened (i.e. app (not) authorized) and then do whatever you want in response to that.

Hope this might help someone out!

Ivan Crojach Karačić
  • 1,911
  • 2
  • 24
  • 44