Mikael Svenson
Mikael Svenson

Reputation: 39695

Microsoft.IdentityModel.Clients.ActiveDirectory v3.17.0 and appid/appsecret

When upgrading from v3.16.1 to v3.17.0 of Microsoft.IdentityModel.Clients.ActiveDirectory I cannot find an overload on how to aquire an access token using an ADAL app with clientId and clientSecret which I previously could pass in as a ClientCredential object.

The below overload of AcquireTokenAsync is no longer present, so what would the approach be going forward?

var clientCredential = new ADAL.ClientCredential(AppId, AppSecret);
var token = await authenticationContext.AcquireTokenAsync(GraphResourceId, clientCredential);

Upvotes: 1

Views: 357

Answers (1)

Fei Xue
Fei Xue

Reputation: 14649

The AcquireTokenAsync is in the class AuthenticationContextConfidentialClientExtensions and still able to use. Please refer the code below(source code):

/// <summary>
/// Acquires security token from the authority.
/// </summary>
/// <param name="ctx">Authentication context instance</param>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientCredential">The client credential to use for token acquisition.</param>
/// <returns>It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.</returns>
public static async Task<AuthenticationResult> AcquireTokenAsync(this AuthenticationContext ctx,
    string resource, ClientCredential clientCredential)
{
    return await ctx.AcquireTokenForClientCommonAsync(resource, new ClientKey(clientCredential))
        .ConfigureAwait(false);
}

Please check it and feel free to let me know if you still have the problem.

Upvotes: 1

Related Questions