Microsoft Azure Developer Associate AZ-204 Practice Question
Your team is building an ASP.NET Core 6 Web API that will be secured by the Microsoft Identity platform. The API must respond with HTTP 401 when no bearer token is present and with HTTP 403 when the token does not contain the access_as_user scope. Which Program.cs configuration meets these requirements?
Call AddMicrosoftIdentityWebApiAuthentication(configuration, "AzureAd") and set JwtBearerOptions.SuppressMapInboundClaims = true without configuring extra policies.
Call AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd")) and enable PKCE.
Call AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => ); do not add additional authorization policies.
Call AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddMicrosoftIdentityWebApi(configuration.GetSection("AzureAd")); then add an authorization policy that requires the access_as_user scope.
Calling AddMicrosoftIdentityWebApi configures the JWT bearer middleware so that unauthenticated requests are intercepted and converted to HTTP 401. Adding an authorization policy that requires the access_as_user scope causes ASP.NET Core to return HTTP 403 when a valid token lacks that scope. The WebApp/OpenID Connect helpers are intended for interactive server-rendered apps, and AddJwtBearer without an explicit scope-checking authorization policy would accept any token that passes signature and audience validation, so it would not generate the required 403 response.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the AddAuthentication method in ASP.NET Core?
Open an interactive chat with Bash
What is an authorization policy in ASP.NET Core and how does it work?
Open an interactive chat with Bash
What is the difference between AddMicrosoftIdentityWebApi and AddMicrosoftIdentityWebApp?
Open an interactive chat with Bash
Microsoft Azure Developer Associate AZ-204
Implement Azure security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .