ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 130 - AZ-204 discussion

Report
Export

HOTSPOT

You are developing a web application that makes calls to the Microsoft Graph API. You register the application in the Azure portal and upload a valid X509 certificate.

You create an appsettings.json file containing the certificate name, client identifier for the application, and the tenant identifier of the Azure Active Directory (Azure AD). You create a method named ReadCertificate to return the X509 certificate by name.

You need to implement code that acquires a token by using the certificate.

How should you complete the code segment? To answer, select the appropriate options in the answer area.

NOTE: Each correct selection is worth one point.


Question 130
Correct answer: Question 130

Explanation:

Box 1: ConfidentialClientApplicationBuilder

Here's the code to instantiate the confidential client application with a client secret:

app = ConfidentialClientApplicationBuilder.Create(config.ClientId)

.WithClientSecret(config.ClientSecret)

.WithAuthority(new Uri(config.Authority))

.Build();

Box 2: scopes

After you've constructed a confidential client application, you can acquire a token for the app by calling AcquireTokenForClient, passing the scope, and optionally forcing a refresh of the token.

Sample code: result = await app.AcquireTokenForClient(scopes)

.ExecuteAsync();

Reference:

https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-daemon-app-configuration

https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-daemon-acquire-token

asked 02/10/2024
Felix Maroto Roman
46 questions
User
0 comments
Sorted by

Leave a comment first