2017-10-10 24 views
1

當從v3.16.1到Microsoft.IdentityModel.Clients.ActiveDirectory v3.17.0升級我無法找到如何使用ADAL應用與clientIdclientSecret將收購的訪問令牌一個重載我以前可以作爲ClientCredential對象傳入。Microsoft.IdentityModel.Clients.ActiveDirectory v3.17.0和的appid/appsecret

AcquireTokenAsync的以下超載不再存在,那麼該方法將會如何前進?

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

回答

1

AcquireTokenAsync是類AuthenticationContextConfidentialClientExtensions,仍然能夠使用。請參考以下(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); 
} 

請檢查並隨時讓我知道,如果你仍然有問題。

+0

似乎它在使用語句清理後再次運行,所以它確實存在:) –

相關問題