语言

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 所需的范围列表。 例如,“user.read mail.read.read”用于Microsoft Graph用户权限。 对于Microsoft标识,对于应用程序令牌(由应用代表自己请求),应只有一个作用域,并且它应以“.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 将在处理请求时引发 MicrosoftIdentityAuthenticationException 。

适用于