You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which version of Microsoft Identity Web are you using?
Microsoft Identity Web 1.9.2
Where is the issue?
Protected web APIs (validating scopes)
Is this a new or an existing app?
This is a new app or an experiment.
Repro
[ApiController][Route("[controller]")][RequiredScope(RequiredScopesConfigurationKey ="AzureAd:Scopes")]publicclassWeatherForecastController:ControllerBase{
...The Code from the Asp.net Core 5.0 Web API Template...}
In appsettings.json
"AzureAd":{"Scopes": "Test.Read"}
Expected behavior
We expect an 401 or 403 response, depending on if the user is authenticated / authorized.
Actual behavior
InvalidOperationException: A suitable constructor for type 'Microsoft.Identity.Web.Resource.RequiredScopeFilter' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
However, if we replace the line
[RequiredScope(RequiredScopesConfigurationKey = "AzureAd:Scopes")]
with a hard coding one
[RequiredScope(new string[] { "Test.Read" })]
then the app will work perfectly.
The text was updated successfully, but these errors were encountered:
martooooo
changed the title
[Bug]
[Bug] Microsoft.Identity.Web.Resource.RequiredScopeFilter 's constructor could not be located when read config from appsettings
May 17, 2021
Which version of Microsoft Identity Web are you using?
Microsoft Identity Web 1.9.2
Where is the issue?
Protected web APIs (validating scopes)
Is this a new or an existing app?
This is a new app or an experiment.
Repro
Expected behavior
We expect an 401 or 403 response, depending on if the user is authenticated / authorized.
Actual behavior
InvalidOperationException: A suitable constructor for type 'Microsoft.Identity.Web.Resource.RequiredScopeFilter' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
However, if we replace the line
[RequiredScope(RequiredScopesConfigurationKey = "AzureAd:Scopes")]
with a hard coding one
[RequiredScope(new string[] { "Test.Read" })]
then the app will work perfectly.
Possible solution
None.
Additional context / logs / screenshots
The above scenario is based on the default asp.net core 5.0 Web API template. We followed the tutorial at https://github.com/AzureAD/microsoft-identity-web/wiki/Web-APIs#verify-scopes-in-web-apis-called-on-behalf-of-users
The text was updated successfully, but these errors were encountered: