the partner returned a bad sign-in name or password error. for more information, see federation error-handling scenarios

Shreeja 21 Reputation points
2021-11-12T10:08:44.417+00:00

Hi,

I have written CSOM in the console app to add Managed Metadata columns to the sharepoint online site

It was working fine all these days but suddenly it started throwing an error as mentioned below even though ID is part of Site Collection Administrators group.

Exactly I am getting the error at the line context.ExecuteQuery();

Please share your inputs to cross over the issue.

Error

The partner returned a bad sign-in name or password error. For more information, see Federation Error-handling Scenarios.

Regards,

Shreeja M S

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,486 Reputation points Microsoft External Staff
    2021-11-15T06:34:05.643+00:00

    Hi @Shreeja ,
    Have your issue fixed? “The sign-in name or password does not match one in the Microsoft account system” Error will occur sometimes and fixed after a while with nothing changed.
    I tested the following code and it runs well:

        ClientContext ctx = new ClientContext("https://xxxx.sharepoint.com/sites/xxx");  
        var strPassword = "*********";  
        SecureString secureString = new SecureString();  
        strPassword.ToList().ForEach(secureString.AppendChar);  
        ctx.Credentials = new SharePointOnlineCredentials("xxxx@****.onmicrosoft.com", secureString);  
        Web site = ctx.Web;  
        ctx.Load(site);  
        ctx.ExecuteQuery();  
        Console.WriteLine("Title: " + site.Title + "; URL: " + site.Url);  
        Console.ReadLine();  
    
        var filePath = "C:\\Users\\xxxx\\Desktop\\test.txt";  
        var libraryName = "Doc99";  
    
        FileCreationInformation fci = new FileCreationInformation();  
        fci.Content = System.IO.File.ReadAllBytes(filePath);  
        fci.Url = Path.GetFileName(filePath);  
        Web web = ctx.Web;  
        List targetDocLib = ctx.Web.Lists.GetByTitle(libraryName);  
        ctx.ExecuteQuery();  
    
        Microsoft.SharePoint.Client.File newFile = targetDocLib.RootFolder.Files.Add(fci);  
        ctx.Load(newFile);  
        ctx.ExecuteQuery();  
    

    So please test your code again. If the error still occurred, our account may be MFA (Multi-factor authentication) enabled. Please follow the steps to disable MFA
    https://learn.microsoft.com/en-us/microsoft-365/admin/security-and-compliance/set-up-multi-factor-authentication?view=o365-worldwide


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful

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.