Пример #1
0
        public void GetTokenFromAzure()
        {
            AuthenticationResult token = null;

            "When I request a Token"
            .x(async() =>
            {
                var clientCredential = new ClientCredential(appKey);
                ConfidentialClientApplication daemonClient = new ConfidentialClientApplication(clientId, authority, redirectUri, clientCredential, null, new TokenCache());
                token = await daemonClient.AcquireTokenForClientAsync(new string[] { "https://graph.microsoft.com/.default" });
            });
            "Then the token should not not be null"
            .x(() =>
            {
                token.Should().NotBeNull(because: "I Just got it no?");
            });
        }
Пример #2
0
        public void GetTokenFromAzure()
        {
            AuthenticationResult token = null;

            "When I request a Token"
            .x(async() =>
            {
                var authContext      = new AuthenticationContext(authority);
                var clientCredential = new ClientCredential(clientId, appKey);
                //var x = await authContext.GetAuthorizationRequestUrlAsync(resourceIdOfAppToConnectTo, clientId, new Uri("https://localhost/"), UserIdentifier.AnyUser, );
                // ADAL includes an in memory cache, so this call will only send a message to the server if the cached token is expired.
                token = await authContext.AcquireTokenAsync(resourceIdOfAppToConnectTo, clientCredential);
            });
            "Then the token should not not be null"
            .x(() =>
            {
                token.Should().NotBeNull(because: "I Just got it no?");
            });
        }