RequiredScopeOrAppPermissionAttribute Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| RequiredScopeOrAppPermissionAttribute() |
Default constructor. |
| RequiredScopeOrAppPermissionAttribute(String[], String[]) |
Declares the scopes and app permissions accepted by this web API.
Authorization succeeds when the token has any of these |
RequiredScopeOrAppPermissionAttribute()
Default constructor.
public RequiredScopeOrAppPermissionAttribute();
Public Sub New ()
Examples
[RequiredScopeOrAppPermission(RequiredScopesConfigurationKey="AzureAD:Scope", RequiredAppPermissionsConfigurationKey="AzureAD:AppPermission")]
class Controller : BaseController
{
}
Applies to
RequiredScopeOrAppPermissionAttribute(String[], String[])
Declares the scopes and app permissions accepted by this web API.
Authorization succeeds when the token has any of these acceptedScopes in its
scope claims or any of these acceptedAppPermissions in its role claims.
public RequiredScopeOrAppPermissionAttribute(string[] acceptedScopes, string[] acceptedAppPermissions);
new Microsoft.Identity.Web.Resource.RequiredScopeOrAppPermissionAttribute : string[] * string[] -> Microsoft.Identity.Web.Resource.RequiredScopeOrAppPermissionAttribute
Public Sub New (acceptedScopes As String(), acceptedAppPermissions As String())
Parameters
- acceptedScopes
- String[]
Scopes accepted by this web API.
- acceptedAppPermissions
- String[]
App permissions accepted by this web API.
Examples
Add the following attribute on the controller/page/action to protect:
[RequiredScopeOrAppPermission(new [] { "access_as_user" }, new [] { "access_as_app" })]
Remarks
When neither the scopes nor app permissions match, the response is a 403 (Forbidden), because the caller is authenticated (hence not 401), but not authorized.
See also
- <xref:RequiredScopeOrAppPermissionAttribute()>