public void ConstructorTests() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = new TokenCache(); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = true, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = cache }; SilentRequest request = new SilentRequest(parameters, (string) null, new PlatformParameters(), false); Assert.IsNotNull(request); request = new SilentRequest(parameters, (User) null, new PlatformParameters(), false); Assert.IsNotNull(request); request = new SilentRequest(parameters, TestConstants.DefaultDisplayableId, new PlatformParameters(), false); Assert.IsNotNull(request); request = new SilentRequest(parameters, TestConstants.DefaultUniqueId, new PlatformParameters(), false); Assert.IsNotNull(request); request = new SilentRequest(parameters, TestConstants.DefaultUser, new PlatformParameters(), false); Assert.IsNotNull(request); }
/// <summary> /// /// </summary> /// <param name="scope"></param> /// <returns></returns> public async Task<AuthenticationResult> AcquireTokenAsync(string[] scope) { Authenticator authenticator = new Authenticator(this.Authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenCommonAsync(authenticator, scope, null, new Uri(this.RedirectUri), (string) null, UiOptions.SelectAccount, null, null).ConfigureAwait(false); }
/// <summary> /// AcquireTokenOnBehalfOfAsync /// </summary> public async Task<AuthenticationResult> AcquireTokenOnBehalfOfAsync(string[] scope, UserAssertion userAssertion) { Authenticator authenticator = new Authenticator(this.Authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenOnBehalfCommonAsync(authenticator, scope, userAssertion, null) .ConfigureAwait(false); }
public ClientKey(string clientId, ClientCredential clientCredential, Authenticator authenticator):this(clientId) { if (clientCredential == null) { throw new ArgumentNullException("clientCredential"); } this.Authenticator = authenticator; this.Credential = clientCredential; this.HasCredential = true; }
public void MapToIdentifierNullInputTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = new TokenCache(); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = true, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = cache }; SilentRequest request = new SilentRequest(parameters, (string)null, new PlatformParameters(), false); User user = request.MapIdentifierToUser(null); Assert.IsNull(user); }
public void MapToIdentifierMultipleMatchingEntriesTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = TokenCacheHelper.CreateCacheWithItems(); TokenCacheKey key = new TokenCacheKey(TestConstants.DefaultAuthorityHomeTenant, TestConstants.ScopeForAnotherResource, TestConstants.DefaultClientId, TestConstants.DefaultUniqueId, TestConstants.DefaultDisplayableId, TestConstants.DefaultHomeObjectId, TestConstants.DefaultPolicy); AuthenticationResultEx ex = new AuthenticationResultEx(); ex.Result = new AuthenticationResult("Bearer", key.ToString(), new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(3600))); ex.Result.User = new User { DisplayableId = TestConstants.DefaultDisplayableId, UniqueId = TestConstants.DefaultUniqueId, HomeObjectId = TestConstants.DefaultHomeObjectId }; ex.Result.ScopeSet = TestConstants.DefaultScope; ex.Result.FamilyId = "1"; ex.RefreshToken = "someRT"; cache.tokenCacheDictionary[key] = ex; AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = new[] { "something" }, TokenCache = cache }; SilentRequest request = new SilentRequest(parameters, (string) null, new PlatformParameters(), false); User user = request.MapIdentifierToUser(TestConstants.DefaultUniqueId); Assert.IsNotNull(user); Assert.AreEqual(TestConstants.DefaultUniqueId, user.UniqueId); }
public void MapToIdentifierItemFoundTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = TokenCacheHelper.CreateCacheWithItems(); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = cache }; SilentRequest request = new SilentRequest(parameters, (string)null, new PlatformParameters(), false); User user = request.MapIdentifierToUser(TestConstants.DefaultUniqueId); Assert.IsNotNull(user); Assert.AreEqual(TestConstants.DefaultUniqueId, user.UniqueId); }
private async Task<AuthenticationResult> AcquireTokenCommonAsync(Authenticator authenticator, string[] scope, string[] additionalScope, Uri redirectUri, User user, UiOptions uiOptions, string extraQueryParameters, string policy) { if (this.PlatformParameters == null) { this.PlatformParameters = PlatformPlugin.DefaultPlatformParameters; } var handler = new InteractiveRequest( this.GetHandlerData(authenticator, scope, policy, this.UserTokenCache), additionalScope, redirectUri, this.PlatformParameters, user, uiOptions, extraQueryParameters, this.CreateWebAuthenticationDialog(this.PlatformParameters)); return await handler.RunAsync().ConfigureAwait(false); }
internal override AuthenticationRequestParameters GetHandlerData(Authenticator authenticator, string[] scope, string policy, TokenCache cache) { AuthenticationRequestParameters parameters = base.GetHandlerData(authenticator, scope, policy, cache); parameters.ClientKey = new ClientKey(this.ClientId, this.ClientCredential, authenticator); return parameters; }
private async Task<AuthenticationResult> AcquireTokenByAuthorizationCodeCommonAsync(string authorizationCode, string[] scope, Uri redirectUri, string policy) { Authenticator authenticator = new Authenticator(this.Authority, this.ValidateAuthority, this.CorrelationId); var handler = new AuthorizationCodeRequest(this.GetHandlerData(authenticator, scope, policy, this.UserTokenCache), authorizationCode, redirectUri); return await handler.RunAsync(); }
private async Task<AuthenticationResult> AcquireTokenForClientCommonAsync(string[] scope, string policy) { Authenticator authenticator = new Authenticator(this.Authority, this.ValidateAuthority, this.CorrelationId); AuthenticationRequestParameters parameters = this.GetHandlerData(authenticator, scope, policy, this.AppTokenCache); parameters.RestrictToSingleUser = false; var handler = new ClientCredentialRequest(parameters); return await handler.RunAsync(); }
/// <summary> /// /// </summary> /// <param name="scope"></param> /// <param name="user"></param> /// <param name="options"></param> /// <param name="extraQueryParameters"></param> /// <param name="additionalScope"></param> /// <param name="authority"></param> /// <param name="policy"></param> /// <returns></returns> public async Task<AuthenticationResult> AcquireTokenAsync(string[] scope, User user, UiOptions options, string extraQueryParameters, string[] additionalScope, string authority, string policy) { Authenticator authenticator = new Authenticator(authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenCommonAsync(authenticator, scope, additionalScope, new Uri(this.RedirectUri), user, options, extraQueryParameters, policy).ConfigureAwait(false); }
public void DuplicateQueryParameterErrorTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = null }; InteractiveRequest request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), (User) null, UiOptions.ForceLogin, "extra=qp&prompt=login", new MockWebUI()); request.PreRunAsync().Wait(); try { request.PreTokenRequest().Wait(); Assert.Fail("MsalException should be thrown here"); } catch (Exception exc) { Assert.IsTrue(exc.InnerException is MsalException); Assert.AreEqual(MsalError.DuplicateQueryParameter, ((MsalException)exc.InnerException).ErrorCode); } }
public void NullUserForActAsCurrentUserTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); try { AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = null }; InteractiveRequest request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), (User) null, UiOptions.ActAsCurrentUser, "extra=qp", new MockWebUI()); Assert.Fail("ArgumentException should be thrown here"); } catch (ArgumentException ae) { Assert.IsTrue(ae.Message.Contains(MsalErrorMessage.LoginHintNullForUiOption)); } }
public void VerifyAuthorizationResultTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); MockWebUI webUi = new MockWebUI(); webUi.MockResult = new AuthorizationResult(AuthorizationStatus.ErrorHttp, TestConstants.DefaultAuthorityHomeTenant + "?error="+OAuthError.LoginRequired); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = null }; InteractiveRequest request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), (string) null, UiOptions.ForceLogin, "extra=qp", webUi); request.PreRunAsync().Wait(); try { request.PreTokenRequest().Wait(); Assert.Fail("MsalException should have been thrown here"); } catch (Exception exc) { Assert.IsTrue(exc.InnerException is MsalException); Assert.AreEqual(MsalError.UserInteractionRequired, ((MsalException)exc.InnerException).ErrorCode); } webUi = new MockWebUI(); webUi.MockResult = new AuthorizationResult(AuthorizationStatus.ErrorHttp, TestConstants.DefaultAuthorityHomeTenant + "?error=invalid_request&error_description=some error description"); request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), (string)null, UiOptions.ForceLogin, "extra=qp", webUi); request.PreRunAsync().Wait(); try { request.PreTokenRequest().Wait(); Assert.Fail("MsalException should have been thrown here"); } catch (Exception exc) { Assert.IsTrue(exc.InnerException is MsalException); Assert.AreEqual("invalid_request", ((MsalException)exc.InnerException).ErrorCode); Assert.AreEqual("some error description", ((MsalException)exc.InnerException).Message); } }
public void CacheWithMultipleUsersAndRestrictToSingleUserTrueTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = TokenCacheHelper.CreateCacheWithItems(); try { AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = true, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = cache }; InteractiveRequest request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), new User {UniqueId = TestConstants.DefaultUniqueId}, UiOptions.ForceLogin, "extra=qp", new MockWebUI()); Assert.Fail("ArgumentException should be thrown here"); } catch (ArgumentException ae) { Assert.AreEqual( "Cache cannot have entries for more than 1 unique id when RestrictToSingleUser is set to TRUE.", ae.Message); } }
public void ActAsCurrentUserNoSsoHeaderForLoginHintOnlyTest() { //this test validates that no SSO header is added when developer passes only login hint and UiOption.ActAsCurrentUser Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = new TokenCache(); TokenCacheKey key = new TokenCacheKey(TestConstants.DefaultAuthorityHomeTenant, TestConstants.DefaultScope, TestConstants.DefaultClientId, TestConstants.DefaultUniqueId, TestConstants.DefaultDisplayableId, TestConstants.DefaultHomeObjectId, TestConstants.DefaultPolicy); AuthenticationResultEx ex = new AuthenticationResultEx(); ex.Result = new AuthenticationResult("Bearer", key.ToString(), new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(3599))); ex.Result.User = new User { DisplayableId = TestConstants.DefaultDisplayableId, UniqueId = TestConstants.DefaultUniqueId, HomeObjectId = TestConstants.DefaultHomeObjectId }; ex.Result.FamilyId = "1"; ex.RefreshToken = "someRT"; cache.tokenCacheDictionary[key] = ex; MockWebUI webUi = new MockWebUI(); webUi.MockResult = new AuthorizationResult(AuthorizationStatus.Success, TestConstants.DefaultAuthorityHomeTenant + "?code=some-code"); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = cache }; InteractiveRequest request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), ex.Result.User, UiOptions.ActAsCurrentUser, "extra=qp", webUi); request.PreRunAsync().Wait(); request.PreTokenRequest().Wait(); }
/// <summary> /// .NET specific method for intergrated auth. /// </summary> /// <param name="scope"></param> /// <param name="authority"></param> /// <param name="policy"></param> /// <returns></returns> internal async Task<AuthenticationResult> AcquireTokenWithIntegratedAuthInternalAsync(string[] scope, string authority, string policy) { Authenticator authenticator = new Authenticator(authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenUsingIntegratedAuthCommonAsync(authenticator, scope, new UserCredential(), policy).ConfigureAwait(false); }
public void ExpiredTokenRefreshFlowTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = TokenCacheHelper.CreateCacheWithItems(); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = new[] { "some-scope1", "some-scope2" }, TokenCache = cache }; HttpMessageHandlerFactory.MockHandler = new MockHttpMessageHandler() { Method = HttpMethod.Post, ResponseMessage = MockHelpers.CreateSuccessTokenResponseMessage() }; SilentRequest request = new SilentRequest(parameters, (string)null, new PlatformParameters(), false); Task<AuthenticationResult> task = request.RunAsync(); AuthenticationResult result = task.Result; Assert.IsNotNull(result); Assert.AreEqual("some-access-token", result.Token); Assert.AreEqual("some-scope1 some-scope2", result.Scope.AsSingleString()); }
public void SilentRefreshFailedNoCacheItemFoundTest() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = new TokenCache(); AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = TestConstants.DefaultPolicy, RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = new[] { "some-scope1", "some-scope2" }, TokenCache = cache }; HttpMessageHandlerFactory.MockHandler = new MockHttpMessageHandler() { Method = HttpMethod.Post, ResponseMessage = MockHelpers.CreateSuccessTokenResponseMessage() }; try { SilentRequest request = new SilentRequest(parameters, (string) null, new PlatformParameters(), false); Task<AuthenticationResult> task = request.RunAsync(); var authenticationResult = task.Result; Assert.Fail("MsalSilentTokenAcquisitionException should be thrown here"); } catch (AggregateException ae) { Assert.IsTrue(ae.InnerException is MsalSilentTokenAcquisitionException); } }
public void NoCacheLookup() { Authenticator authenticator = new Authenticator(TestConstants.DefaultAuthorityHomeTenant, false, Guid.NewGuid()); TokenCache cache = new TokenCache(); TokenCacheKey key = new TokenCacheKey(TestConstants.DefaultAuthorityHomeTenant, TestConstants.DefaultScope, TestConstants.DefaultClientId, TestConstants.DefaultUniqueId, TestConstants.DefaultDisplayableId, TestConstants.DefaultHomeObjectId, TestConstants.DefaultPolicy); AuthenticationResultEx ex = new AuthenticationResultEx(); ex.Result = new AuthenticationResult("Bearer", key.ToString(), new DateTimeOffset(DateTime.UtcNow + TimeSpan.FromSeconds(3599))); ex.Result.User = new User { DisplayableId = TestConstants.DefaultDisplayableId, UniqueId = TestConstants.DefaultUniqueId, HomeObjectId = TestConstants.DefaultHomeObjectId }; ex.Result.FamilyId = "1"; ex.RefreshToken = "someRT"; cache.tokenCacheDictionary[key] = ex; IWebUI ui = Substitute.For<IWebUI>(); AuthorizationResult ar = new AuthorizationResult(AuthorizationStatus.Success, TestConstants.DefaultAuthorityHomeTenant + "?code=some-code"); ui.AcquireAuthorizationAsync(Arg.Any<Uri>(), Arg.Any<Uri>(), Arg.Any<IDictionary<string, string>>(), Arg.Any<CallState>()) .Returns(ar); MockHttpMessageHandler mockHandler = new MockHttpMessageHandler(); mockHandler.Method = HttpMethod.Post; mockHandler.QueryParams = new Dictionary<string, string>() {{"p", "some-policy"}}; mockHandler.ResponseMessage = MockHelpers.CreateSuccessTokenResponseMessage(); HttpMessageHandlerFactory.MockHandler = mockHandler; AuthenticationRequestParameters parameters = new AuthenticationRequestParameters() { Authenticator = authenticator, ClientKey = new ClientKey(TestConstants.DefaultClientId), Policy = "some-policy", RestrictToSingleUser = TestConstants.DefaultRestrictToSingleUser, Scope = TestConstants.DefaultScope.ToArray(), TokenCache = cache }; InteractiveRequest request = new InteractiveRequest(parameters, TestConstants.ScopeForAnotherResource.ToArray(), new Uri("some://uri"), new PlatformParameters(), TestConstants.DefaultDisplayableId, UiOptions.SelectAccount, "extra=qp", ui); Task<AuthenticationResult> task = request.RunAsync(); task.Wait(); AuthenticationResult result = task.Result; Assert.IsNotNull(result); Assert.AreEqual(2, cache.Count); Assert.AreEqual(result.Token, "some-access-token"); //both cache entry authorities are TestConstants.DefaultAuthorityHomeTenant foreach (var item in cache.ReadItems(TestConstants.DefaultClientId)) { Assert.AreEqual(TestConstants.DefaultAuthorityHomeTenant, item.Authority); } }
/// <summary> /// /// </summary> /// <param name="scope"></param> /// <param name="userIdentifier"></param> /// <returns></returns> public async Task<AuthenticationResult> AcquireTokenSilentAsync(string[] scope, string userIdentifier) { Authenticator authenticator = new Authenticator(this.Authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenSilentCommonAsync(authenticator, scope, userIdentifier, this.PlatformParameters, null, false).ConfigureAwait(false); }
/// <summary> /// /// </summary> /// <param name="scope"></param> /// <param name="loginHint"></param> /// <param name="extraQueryParameters"></param> /// <param name="options"></param> /// <returns></returns> public async Task<AuthenticationResult> AcquireTokenAsync(string[] scope, string loginHint, UiOptions options, string extraQueryParameters) { Authenticator authenticator = new Authenticator(this.Authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenCommonAsync(authenticator, scope, null, new Uri(this.RedirectUri), loginHint, options, extraQueryParameters, null).ConfigureAwait(false); }
private async Task<AuthenticationResult> AcquireTokenOnBehalfCommonAsync(Authenticator authenticator, string[] scope, UserAssertion userAssertion, string policy) { var handler = new OnBehalfOfRequest(this.GetHandlerData(authenticator, scope, policy, this.UserTokenCache), userAssertion); return await handler.RunAsync(); }
internal async Task<AuthenticationResult> AcquireTokenSilentCommonAsync(Authenticator authenticator, string[] scope, User user, IPlatformParameters parameters, string policy, bool forceRefresh) { if (parameters == null) { parameters = PlatformPlugin.DefaultPlatformParameters; } var handler = new SilentRequest(this.GetHandlerData(authenticator, scope, policy, this.UserTokenCache), user, parameters, forceRefresh); return await handler.RunAsync().ConfigureAwait(false); }
/// <summary> /// Gets URL of the authorize endpoint including the query parameters. /// </summary> /// <param name="scope"></param> /// <param name="redirectUri"></param> /// <param name="loginHint"></param> /// <param name="extraQueryParameters"></param> /// <param name="additionalScope"></param> /// <param name="authority"></param> /// <param name="policy"></param> /// <returns>URL of the authorize endpoint including the query parameters.</returns> public async Task<Uri> GetAuthorizationRequestUrlAsync(string[] scope, string redirectUri, string loginHint, string extraQueryParameters, string[] additionalScope, string authority, string policy) { Authenticator authenticator = new Authenticator(authority, this.ValidateAuthority, this.CorrelationId); AuthenticationRequestParameters parameters = this.GetHandlerData(authenticator, scope, policy, this.UserTokenCache); parameters.ClientKey = new ClientKey(this.ClientId); var handler = new InteractiveRequest(parameters, additionalScope, new Uri(redirectUri), null, loginHint, null, extraQueryParameters, null); return await handler.CreateAuthorizationUriAsync(this.CorrelationId).ConfigureAwait(false); }
internal virtual AuthenticationRequestParameters GetHandlerData(Authenticator authenticator, string[] scope, string policy, TokenCache cache) { return new AuthenticationRequestParameters { Authenticator = authenticator, Scope = scope, Policy = policy, RestrictToSingleUser = this.RestrictToSingleUser, TokenCache = cache }; }
/// <summary> /// /// </summary> /// <param name="scope"></param> /// <param name="user"></param> /// <param name="authority"></param> /// <param name="policy"></param> /// <param name="forceRefresh"></param> /// <returns></returns> public async Task<AuthenticationResult> AcquireTokenSilentAsync(string[] scope, User user, string authority, string policy, bool forceRefresh) { Authenticator authenticator = new Authenticator(authority, this.ValidateAuthority, this.CorrelationId); return await this.AcquireTokenSilentCommonAsync(authenticator, scope, user, this.PlatformParameters, policy, forceRefresh).ConfigureAwait(false); }
private async Task<AuthenticationResult> AcquireTokenUsingIntegratedAuthCommonAsync(Authenticator authenticator, string[] scope, UserCredential userCredential, string policy) { var handler = new SilentWebUiRequest(this.GetHandlerData(authenticator, scope, policy, this.UserTokenCache), userCredential); return await handler.RunAsync().ConfigureAwait(false); }