locked
An error occurred while sending the request exception while AcquireTokenForClient RRS feed

  • Question

  • Hi team,

    I am getting an exception while running the below code from server

    var ewsScopes = new string[] { "https://outlook.office.com/.default" };

                var app = ConfidentialClientApplicationBuilder.Create(ConfigurationManager.AppSettings["appId"])
                    .WithAuthority(AzureCloudInstance.AzurePublic, ConfigurationManager.AppSettings["tenantId"])
                    .WithClientSecret(ConfigurationManager.AppSettings["clientSecret"])
                    .Build();

                AuthenticationResult result = null;
                try
                {

                    result = await app.AcquireTokenForClient(ewsScopes).ExecuteAsync();
                }
                catch (Exception ex1)
                {
                    throw ex1;
                }

    Exception : An error occurred while sending the request

    And this on result = await app.AcquireTokenForClient(ewsScopes).ExecuteAsync(); line.

    Please note : the code is running fine when the application is running with AD users - only getting exception when i use a service account.

    Regards,

    Nidheesh

    Monday, September 14, 2020 7:46 PM

All replies

  • Hello,

    For Azure quesiton -> https://docs.microsoft.com/en-us/answers/index.html


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, September 15, 2020 2:22 AM