コード例 #1
0
        public async Task <IActionResult> Index()
        {
            var tokenResponse = await ClientCredentials.GetAccessToken();

            var claims = await ClientCredentials.CallApi(tokenResponse.AccessToken);

            return(View(claims));
        }
コード例 #2
0
        public static async Task <ServiceClientCredentials> LogonWithEryphClient(ClientCredentials credentials, IEnumerable <string> scopes)
        {
            var scopesArray = scopes as string[] ?? scopes.ToArray();

            var accessTokenResponse =
                await credentials.GetAccessToken(scopesArray).ConfigureAwait(false);

            return(new TokenCredentials(new ApplicationTokenProvider(credentials, accessTokenResponse, scopesArray)));
        }
コード例 #3
0
        static async Task Main(string[] args)
        {
            try
            {
                var tokenResponse = await ClientCredentials.GetAccessToken();

                Console.WriteLine(tokenResponse.Json);
                var claims = await ClientCredentials.CallApi(tokenResponse.AccessToken);

                Console.WriteLine(claims);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #4
0
 public Task <AccessTokenResponse> AuthenticateAsync(string audience, IEnumerable <string> scopes)
 {
     return(_clientCredentials.GetAccessToken(scopes));
 }