0

My application is WPF, written in C# in VisualStudio 2017, using the Dropbox API v2.

I'm trying to obtain an AccessToken for Dropbox and am following the OAuth 2 code on the Dropbox developer's website: https://github.com/dropbox/dropbox-sdk-dotnet/tree/master/dropbox-sdk-dotnet/Examples/SimpleTest

My issue is I am receiving a Script Error when the Dropbox Login page loads. The error is:

Line: 0, Char: 0, Error: Script Error, Code: 0, URL: https://cfl.dropboxstatic.com/static/compiled/js/alameda_bundle/alameda_bundle.min-vflHAZfb_.js

I m sure my redirect Uri is correct and registered because I changed my default web browser from Edge to Explorer and then to Chrome, and each time the log-in worked once (and returned a token) but then threw the same error. The scripting error is now thrown on any of my browsers. I've checked the security settings and scripting is enabled on all.

Here's the XAML:

<local:DropboxBrowser Grid.Row="0" Grid.Column="0"
                      AccessToken="{Binding AccessToken, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
                      UserId="{Binding UserId, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
                      Result="{Binding Result, UpdateSourceTrigger=PropertyChanged}" />

And the key parts of my method:

    private void WebBrowser_Navigating(object sender, NavigatingCancelEventArgs e)
    {
        if (!e.Uri.ToString().StartsWith(REDIRECT_URI, StringComparison.OrdinalIgnoreCase))
        {
            return;
        }

        try
        {
            OAuth2Response result = DropboxOAuth2Helper.ParseTokenFragment(e.Uri);
            if (result.State != _oauth2State)
            {
                return;
            }

            AccessToken = result.AccessToken;
            UserId = result.Uid;
            Result = true;
        }
        catch (ArgumentException ex)
        {
            Debug.WriteLine(ex.Message + ex.StackTrace);
        }
        finally
        {
            e.Cancel = true;
        }
    }

I'm developing with an MVVM architecture, but for now I've reduced my code to a straight lift from Dropbox's example - hence the horrible mix of bindings and code-behind, but I'll sort that out once I have the authentication working.

Does anyone know what I might be doing wrong here?

7
  • I have the same issue with a previously working code. Seem to be the problem in on the Dropbox's side. Commented Apr 30, 2018 at 6:37
  • @AndreyShcherbakov, that's a blow ... did you come up with any workaround solutions?
    – Ambie
    Commented Apr 30, 2018 at 10:22
  • No workaround yet. I posted this on their support forum: dropboxforum.com/t5/API-Support-Feedback/… Commented May 1, 2018 at 7:21
  • @AndreyShcherbakov, thanks, be interesting to hear what they have to say. My feeling is it's something to do with version of IE being used in Webbrowser control. If you're interested, I replaced my webbrowser control with a CefSharp control (cefsharp.github.io) and authentication now works ... does have drawbacks though.
    – Ambie
    Commented May 1, 2018 at 10:43
  • Thanks for the reports! This does seem to be due to the underlying browser/version used by the web view and its compatibility with the Dropbox site. For this reason, we do now highly reccomend only using a supported system browser and not a web view. Ambie, I'm glad to found workaround. I'll follow up on the forum thread though.
    – Greg
    Commented May 1, 2018 at 14:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.