MicrosoftIdentityMessageHandlerOptions.Scopes 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定範圍來請求該標記。
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 。