QuestionQ98
VerifiedConnect to and consume Azure services and third-party servicesYou are building a web application that calls 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, the application's client identifier, and the Azure Active Directory (Azure AD) tenant identifier. 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?
Select
AuthenticationConfig config = AuthenticationConfig.ReadFromJsonFile("appsettings.json"); X509Certificate2 certificate = ReadCertificate(config.CertificateName); var app = .Create(config.ClientId) .WithCertificate(certificate) .WithAuthority(new Uri(config.Authority)) .Build(); string[] scopes = new string[] { $"{config.ApiUrl}.default" }; AuthenticationResult result = await app.AcquireTokenForClient().ExecuteAsync();
Community Discussion