Skip to content

Instantly share code, notes, and snippets.

@thomashagstrom
Created January 11, 2019 13:11
Show Gist options
  • Save thomashagstrom/72b469a86e7701c64c5eefd3534e38ee to your computer and use it in GitHub Desktop.
Save thomashagstrom/72b469a86e7701c64c5eefd3534e38ee to your computer and use it in GitHub Desktop.
WebViewOnNavigating method
private async void WebViewOnNavigating(object sender, WebNavigatingEventArgs e)
{
if (!e.Url.StartsWith(RedirectUri, StringComparison.OrdinalIgnoreCase))
{
// we need to ignore all navigation that isn't to the redirect uri.
return;
}
try
{
var result = DropboxOAuth2Helper.ParseTokenFragment(new Uri(e.Url));
if (result.State != this.oauth2State)
{
return;
}
this.AccessToken = result.AccessToken;
await SaveDropboxToken(this.AccessToken);
this.OnAuthenticated?.Invoke();
}
catch (ArgumentException)
{
// There was an error in the URI passed to ParseTokenFragment
}
finally
{
e.Cancel = true;
await Application.Current.MainPage.Navigation.PopModalAsync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment