How to get access token with Azure.Identity.AuthenticationFailedException....

Matt Salisbury 0 Reputation points
2025-04-22T09:23:12.7166667+00:00

Hi

I am trying to access my app on Azure to give me an Access Token. However there seems to be no way of avoiding this error:

Azure.Identity.AuthenticationFailedException: 'InteractiveBrowserCredential authentication failed: '

MsalServiceException: AADSTS650057: Invalid resource. The client has requested access to a resource which is not listed in the requested permissions in the client's application registration.

This is the code which is firing up the credential browser, but then crashes when the Asyc returns...

All the permissions seems to be register in Microsoft_AAD_RegisteredApps, i.e. in the portal....

credential = new InteractiveBrowserCredential(
    new InteractiveBrowserCredentialOptions
    {
        TokenCachePersistenceOptions = new TokenCachePersistenceOptions { Name = TOKEN_CACHE_NAME},
        ClientId = clientId,
        TenantId = tenantId,
        RedirectUri = new Uri("https://localhost/")

    });
//

// Call AuthenticateAsync to fetch a new AuthenticationRecord.
var authRecord =  credential.AuthenticateAsync().SyncResult();
```All the permissions seems to be register in Microsoft_AAD_RegisteredApps, i.e. in the portal....

Microsoft Entra Internet Access
Microsoft Entra Internet Access
A Microsoft Entra service that provides an identity-centric Secure Web Gateway that protects access to internet, software as a service (SaaS), and Microsoft 365 apps and resources.
49 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.