Share via

How to generate the access Token to access the Proxy Application using AcquireTokenSilent method.

Deshmukh, Ashish 1 Reputation point
2024-03-01T06:28:03.2433333+00:00

How to generate the access Token to access the Proxy Application using AcquireTokenSilent method.

I have used the AcquireTokenSilent method but the method returns null result.

Below is the code snippet

**var scopes = new string[] { todoListResourceId + "/user_impersonation" };

        AuthenticationResult authResult;

        //authResult = await clientApp.AcquireTokenSilent(scopes, account).ExecuteAsync();

        try

        {

            authResult = await clientApp.AcquireTokenSilent(scopes, account).ExecuteAsync();

            //authResult = await 

        }

        catch (MsalUiRequiredException ex)

        {

            authResult = await clientApp.AcquireTokenInteractive(scopes).ExecuteAsync();

        }**

Here in** authResult ** i am getting null result.

Thanks :)

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 83,581 Reputation points Volunteer Moderator
    2024-03-02T16:06:58.98+00:00

    AcquireTokenSilent() is used to get the cached token tied to the users login identity. If expire and a refresh token is available, it will the refresh token to get the access token.

    this all requires the user has successfully authenticated and the token was stored. Also if a server farm, a distributed cache is required.

    show your configuration code for the initial authentication.

    0 comments No comments

Your answer

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