語言

MicrosoftIdentityMessageHandlerOptions.Scopes 屬性

定義

取得或設定範圍來請求該標記。

public System.Collections.Generic.IList<string> Scopes { get; set; }
member this.Scopes : System.Collections.Generic.IList<string> with get, set
Public Property Scopes As IList(Of String)

屬性值

存取目標 API 所需的範圍清單。 例如,Microsoft Graph 使用者權限的「user.read mail.read」。 對於 Microsoft Identity,應用程式代表自身請求的應用程式權杖,應該只有一個範圍,且應該以「.default」結尾(例如,「https://graph.microsoft.com/.default")。

範例

var options = new MicrosoftIdentityMessageHandlerOptions();
options.Scopes.Add("https://graph.microsoft.com/.default");
options.Scopes.Add("https://myapi.domain.com/access");

備註

此屬性必須至少包含一個作用域,否則在 MicrosoftIdentityMessageHandler 處理請求時會拋出 a MicrosoftIdentityAuthenticationException 。

適用於