Created
January 11, 2019 13:11
-
-
Save thomashagstrom/72b469a86e7701c64c5eefd3534e38ee to your computer and use it in GitHub Desktop.
WebViewOnNavigating method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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