public static async Task <AuthResult> GetTokenByAuthCodeAsync(string authorizationCode, Microsoft.Identity.Client.TokenCache tokenCache, string[] scopes) { Microsoft.Identity.Client.ConfidentialClientApplication client = new Microsoft.Identity.Client.ConfidentialClientApplication(AuthSettings.ClientId, AuthSettings.RedirectUrl, new Microsoft.Identity.Client.ClientCredential(AuthSettings.ClientSecret), tokenCache); Uri redirectUri = new Uri(AuthSettings.RedirectUrl); var result = await client.AcquireTokenByAuthorizationCodeAsync(scopes, authorizationCode); AuthResult authResult = AuthResult.FromMSALAuthenticationResult(result, tokenCache); return(authResult); }
public static async Task <AuthResult> GetTokenByAuthCodeAsync(string authorizationCode, Microsoft.Identity.Client.TokenCache tokenCache) { Microsoft.Identity.Client.ConfidentialClientApplication client = new Microsoft.Identity.Client.ConfidentialClientApplication(AuthSettings.ClientId, AuthSettings.RedirectUrl, new Microsoft.Identity.Client.ClientCredential(AuthSettings.ClientSecret), tokenCache); Uri redirectUri = new Uri(AuthSettings.RedirectUrl); //Temporary workaround since the current experimental library is unable to decode the token in v2 //var result2 = await GetTokenFromAuthCodeAsyncV2(activeDirectoryEndpointUrl.Value, activeDirectoryTenant.Value, scopes.Value, clientId.Value, clientSecret.Value, authorizationCode, redirectUri.ToString()); var result = await client.AcquireTokenByAuthorizationCodeAsync(AuthSettings.Scopes, authorizationCode); AuthResult authResult = AuthResult.FromMSALAuthenticationResult(result, tokenCache); return(authResult); }