簡體   English   中英

Azure Native Client身份驗證

[英]Azure Native Client Authentication

我在Azure上創建了一個本機應用程序,但我不確定如何僅使用客戶端ID獲取訪問令牌。 我之前使用的是一個Web應用程序,我有一個客戶端ID和密碼,並使用它們進行身份驗證。 我嘗試過使用AcquireTokenSilentlyAsync,但我不能這樣做。

您可以使用如下的AcquireToken方法。 這將彈出一個瀏覽器對話框,詢問您的憑據。

private static string GetToken(string authority, string clientId, string redirectUri)
{
    var authContext = new AuthenticationContext(authority, validateAuthority: false);
    var result = authContext.AcquireToken("https://graph.windows.net",
        clientId, new Uri(redirectUri), PromptBehavior.Auto);

    return result.AccessToken;
}

如果要在不提示用戶的情況下進行身份驗證,請查看資源所有者憑據授予。 Vittorio Bertocci在本文對此進行了解釋。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM