예제 #1
0
        private static async Task RunAuthCode_Async(MockHttpManager httpManager, ConfidentialClientApplication app)
        {
            httpManager.AddSuccessTokenResponseMockHandlerForPost();
            var result = await app
                         .AcquireTokenByAuthorizationCode(TestConstants.s_scope, "some-code")
                         .ExecuteAsync(CancellationToken.None)
                         .ConfigureAwait(false);

            Assert.AreEqual(TokenSource.IdentityProvider, result.AuthenticationResultMetadata.TokenSource);

            var acc = await app.GetAccountAsync(result.Account.HomeAccountId.Identifier).ConfigureAwait(false);

            result = await app.AcquireTokenSilent(TestConstants.s_scope, acc).ExecuteAsync().ConfigureAwait(false);

            Assert.AreEqual(TokenSource.Cache, result.AuthenticationResultMetadata.TokenSource);
        }