PublicClientApplication.AcquireTokenWithDeviceCode 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
透過讓使用者在另一台裝置上進行認證,在沒有網頁瀏覽器的裝置上取得安全憑證。 這過程分為兩個步驟:
- 該方法首先從權威機構取得裝置代碼,並透過
deviceCodeResultCallback. 這個回調負責與使用者互動,指示他們驗證(指向特定網址,並附有代碼) - 接著,該方法會輪詢安全權杖,使用者根據裝置代碼資訊,成功登入後會授予該權杖
public Microsoft.Identity.Client.AcquireTokenWithDeviceCodeParameterBuilder AcquireTokenWithDeviceCode(System.Collections.Generic.IEnumerable<string> scopes, Func<Microsoft.Identity.Client.DeviceCodeResult,System.Threading.Tasks.Task> deviceCodeResultCallback);
abstract member AcquireTokenWithDeviceCode : seq<string> * Func<Microsoft.Identity.Client.DeviceCodeResult, System.Threading.Tasks.Task> -> Microsoft.Identity.Client.AcquireTokenWithDeviceCodeParameterBuilder
override this.AcquireTokenWithDeviceCode : seq<string> * Func<Microsoft.Identity.Client.DeviceCodeResult, System.Threading.Tasks.Task> -> Microsoft.Identity.Client.AcquireTokenWithDeviceCodeParameterBuilder
Public Function AcquireTokenWithDeviceCode (scopes As IEnumerable(Of String), deviceCodeResultCallback As Func(Of DeviceCodeResult, Task)) As AcquireTokenWithDeviceCodeParameterBuilder
參數
- scopes
- IEnumerable<String>
請求存取受保護 API 的範圍
- deviceCodeResultCallback
- Func<DeviceCodeResult,Task>
回撥包含資訊,讓使用者了解如何驗證並輸入裝置代碼。
傳回
一個建構器,讓你在執行 token 請求前能加入可選參數
實作
備註
你也可以透過呼叫 Microsoft.Identity.Client.AbstractAcquireTokenParameterBuilder`1.WithExtraQueryParameters(System.Collections.Generic.Dictionary{System.String,System.String}) :傳遞額外查詢參數給 STS,以及覆蓋 的 WithAuthority(String, Boolean) 其中一個,以覆蓋應用程式建構時的預設權限設定。 請注意,優先權限必須是加入申請結構的已知權限的一部分。