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?