The account password has expired, as specified by the account settings

Viewed 139

I have an asp.net application which connects to SharePoint online site and retrieves data. This functionality has been working fine for months. But, since yesterday I started seeing the following error,

The account password has expired, as specified by the account settings.

I verified the service account that is used to access SharePoint online site and it is good. Its password is already set to not expire and the service account is working fine. I am guessing the above error is misleading. Anyone faced similar issue?

Code:

public static async Task<HttpResponseMessage> SendAsync(HttpMethod httpMethod, string restUrl, string userName, string key, string acceptHeader)
    {
        Uri endpointUri = new Uri(restUrl);

        var securePassword = new SecureString();

        foreach (var keyChar in key)
        {
            securePassword.AppendChar(keyChar);
        }
        var credentials = new SharePointOnlineCredentials(userName, securePassword);

        using (var handler = new HttpClientHandler() { Credentials = credentials })
        {
            handler.CookieContainer.SetCookies(endpointUri, credentials.GetAuthenticationCookie(endpointUri));

            using (var client = new HttpClient(handler))
            {
                client.DefaultRequestHeaders.Accept.Clear();

                if (!string.IsNullOrWhiteSpace(acceptHeader))
                {
                    MediaTypeWithQualityHeaderValue mediaTypeWithQualityHeaderValue = MediaTypeWithQualityHeaderValue.Parse(acceptHeader);
                    client.DefaultRequestHeaders.Accept.Add(mediaTypeWithQualityHeaderValue);
                }

                return await client.GetAsync(endpointUri).ConfigureAwait(false);
            }
        }
    }

I am using Microsoft.SharePointOnline.CSOM 16.1.21213.12000

Any suggestion will be greatly appreciated.

0 Answers
Related