private Token GetTokenWithPrompt(OAuthLowLevel oAuth, OAuthOptions options) { Token token = null; using (DefaultWebBrowserOverride webBrowserOverride = new DefaultWebBrowserOverride(new AuthorisationResultUrlChecker())) { _cancellationTokenSource = new CancellationTokenSource(); Auth0ClientBase client = CreateAuth0Client(); var startResult = Task.Run(() => oAuth.BeginAuthorisationAsync(client, Audience, options)).Result; string endUrl = Task.Run(() => webBrowserOverride.NavigateToStartUrlAsync(new Uri(startResult.StartUrl), _cancellationTokenSource.Token)).Result; var endResult = Task.Run(() => oAuth.EndAuthorisationAsync(client, startResult, endUrl, ClientID, Scope, Audience, StoragePartition)).Result; token = endResult.AccessToken; } return(token); }
private Token GetTokenSilently(OAuthLowLevel oAuth) { Token token = null; token = oAuth.RetrieveExistingAccessToken(ClientID, Scope, Audience, StoragePartition); if (token == null) { Token refreshToken = oAuth.RetrieveExistingRefreshToken(ClientID, Scope, Audience, StoragePartition); if (refreshToken != null) { Auth0ClientBase client = CreateAuth0Client(); AuthorisationResult result = Task.Run(() => oAuth.RefreshAccessTokenAsync(client, refreshToken, ClientID, Scope, Audience, StoragePartition)).Result; token = result.AccessToken; } } return(token); }