{"id":2122,"date":"2020-04-15T23:45:25","date_gmt":"2020-04-15T23:45:25","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=2122"},"modified":"2022-02-03T11:24:26","modified_gmt":"2022-02-03T17:24:26","slug":"console-app-for-sharepoint-online-with-mfa-turned-on","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/","title":{"rendered":"Console App for Sharepoint Online with MFA turned on."},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignright size-large\"><a href=\"https:\/\/devopsreactions.tumblr.com\/post\/57954015770\/customer-suggesting-deployment-on-a-friday\"><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/iH5nnIb.gif\" alt=\"\"\/><\/a><figcaption>Customers suggesting a deployment on a Friday (click for credit)<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">First, I couldn&#8217;t write the title until I got to a) the correct example online, then b) the proper credentials (a work-mate(s) hinted towards the answer) and c) the exact exception text &#8220;The sign-in name or password does not match one in the Microsoft account system.&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sharepoint &#8211; as usual &#8230; SUPER FOR CONTRACTORS WHO GET PAID THE HOUR. (argggg).<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">First &#8211; do NOT use .net Core &#8211; use .net 7.7.x or 4.8. As a last ditch effort &#8211; I used this and boom all my previous experiments worked. FINALLY Success. Read the next paragraph and do NOT get fooled by the word &#8220;Core&#8221; in the needed NuGET package SharepointPNPCoreOnline .<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Second &#8211; include the NuGet package SharepointPNPCoreOnline<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A buddy and I found the main links together while screen sharing. I thank him for the head start &#8211; next was the MFA. A colleague hinted that our username is NOT first.last@mycompany.com but first.last@sharepointfrontpart.onmicrosoft.com so all this together and some google-fu and we have a solution!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then here is your .NET class. I am sure there is a .NetCore solution &#8211; but at this point &#8211; I am happy to have gotten a context \ud83d\ude42 <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing Microsoft.SharePoint.Client;\nusing System.Security;\n\nnamespace ConsoleAppSP_Net1\n{\n    class Class1\n    {\n        public string site_url = &quot;https:\/\/joescompanyonline.sharepoint.com\/sites\/BEST-SITE-EVER\/&quot;;\n        \n        public void try2_THIS_ONE_WORKS_FOR_MFA()\n        {\n\n            var authenticationManager = new OfficeDevPnP.Core.AuthenticationManager();\n\n            ClientContext context = authenticationManager.GetWebLoginClientContext(site_url, null);\n\n            Web web = context.Web;\n            User user = web.CurrentUser;\n            context.Load(web);\n            context.Load(user);\n            context.ExecuteQuery();\n            Console.WriteLine(web.Title);\n            Console.WriteLine(user.LoginName);\n            Console.ReadLine();\n\n        }\n     }\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">So in order of thanks &#8211; here are the links<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.c-sharpcorner.com\/article\/connect-to-sharepoint-online-in-office-365-using-console-application\/\">https:\/\/www.c-sharpcorner.com\/article\/connect-to-sharepoint-online-in-office-365-using-console-application\/<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed-wordpress wp-block-embed is-type-wp-embed is-provider-knowledge-junction\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/knowledge-junction.com\/2017\/12\/24\/office-365-connecting-to-sharepoint-online-site-using-csom-when-multi-factor-authentication-mfa-is-enabled-for-the-user\/\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/c001d13c-3c25-40f1-9993-a3698d9b3639\/sharepoint-online-mfa-csom-the-signin-name-or-password-does-not-match-one-in-the-microsoft?forum=sharepointdevelopment\">https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/c001d13c-3c25-40f1-9993-a3698d9b3639\/sharepoint-online-mfa-csom-the-signin-name-or-password-does-not-match-one-in-the-microsoft?forum=sharepointdevelopment<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.c-sharpcorner.com\/article\/authenticate-sharepoint-using-pnp-authentication-manager\/\">https:\/\/www.c-sharpcorner.com\/article\/authenticate-sharepoint-using-pnp-authentication-manager\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/pnp\/PnP-Sites-Core\/\">https:\/\/github.com\/pnp\/PnP-Sites-Core\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/c001d13c-3c25-40f1-9993-a3698d9b3639\/sharepoint-online-mfa-csom-the-signin-name-or-password-does-not-match-one-in-the-microsoft?forum=sharepointdevelopment\">https:\/\/social.msdn.microsoft.com\/Forums\/en-US\/c001d13c-3c25-40f1-9993-a3698d9b3639\/sharepoint-online-mfa-csom-the-signin-name-or-password-does-not-match-one-in-the-microsoft?forum=sharepointdevelopment<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a link that I goes through all the authentications and why you might want to use them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.c-sharpcorner.com\/article\/authenticate-sharepoint-using-pnp-authentication-manager\/\">https:\/\/www.c-sharpcorner.com\/article\/authenticate-sharepoint-using-pnp-authentication-manager\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/csharp.hotexamples.com\/examples\/OfficeDevPnP.Core\/AuthenticationManager\/-\/php-authenticationmanager-class-examples.html\">https:\/\/csharp.hotexamples.com\/examples\/OfficeDevPnP.Core\/AuthenticationManager\/-\/php-authenticationmanager-class-examples.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, I couldn&#8217;t write the title until I got to a) the correct example online, then b) the proper credentials (a work-mate(s) hinted towards the answer) and c) the exact exception text &#8220;The sign-in name or password does not match one in the Microsoft account system.&#8221; Sharepoint &#8211; as usual &#8230; SUPER FOR CONTRACTORS WHO [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2122","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Console App for Sharepoint Online with MFA turned on. - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Console App for Sharepoint Online with MFA turned on. - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"First, I couldn&#8217;t write the title until I got to a) the correct example online, then b) the proper credentials (a work-mate(s) hinted towards the answer) and c) the exact exception text &#8220;The sign-in name or password does not match one in the Microsoft account system.&#8221; Sharepoint &#8211; as usual &#8230; SUPER FOR CONTRACTORS WHO [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-15T23:45:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:24:26+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/i.imgur.com\/iH5nnIb.gif\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"Console App for Sharepoint Online with MFA turned on.\",\"datePublished\":\"2020-04-15T23:45:25+00:00\",\"dateModified\":\"2022-02-03T17:24:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/\"},\"wordCount\":328,\"image\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/i.imgur.com\\\/iH5nnIb.gif\",\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/\",\"name\":\"Console App for Sharepoint Online with MFA turned on. - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/i.imgur.com\\\/iH5nnIb.gif\",\"datePublished\":\"2020-04-15T23:45:25+00:00\",\"dateModified\":\"2022-02-03T17:24:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#primaryimage\",\"url\":\"http:\\\/\\\/i.imgur.com\\\/iH5nnIb.gif\",\"contentUrl\":\"http:\\\/\\\/i.imgur.com\\\/iH5nnIb.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/console-app-for-sharepoint-online-with-mfa-turned-on\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Console App for Sharepoint Online with MFA turned on.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Console App for Sharepoint Online with MFA turned on. - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/","og_locale":"en_US","og_type":"article","og_title":"Console App for Sharepoint Online with MFA turned on. - ELB Solutions.com Inc.","og_description":"First, I couldn&#8217;t write the title until I got to a) the correct example online, then b) the proper credentials (a work-mate(s) hinted towards the answer) and c) the exact exception text &#8220;The sign-in name or password does not match one in the Microsoft account system.&#8221; Sharepoint &#8211; as usual &#8230; SUPER FOR CONTRACTORS WHO [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2020-04-15T23:45:25+00:00","article_modified_time":"2022-02-03T17:24:26+00:00","og_image":[{"url":"http:\/\/i.imgur.com\/iH5nnIb.gif","type":"","width":"","height":""}],"author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"Console App for Sharepoint Online with MFA turned on.","datePublished":"2020-04-15T23:45:25+00:00","dateModified":"2022-02-03T17:24:26+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/"},"wordCount":328,"image":{"@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#primaryimage"},"thumbnailUrl":"http:\/\/i.imgur.com\/iH5nnIb.gif","articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/","url":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/","name":"Console App for Sharepoint Online with MFA turned on. - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"primaryImageOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#primaryimage"},"image":{"@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#primaryimage"},"thumbnailUrl":"http:\/\/i.imgur.com\/iH5nnIb.gif","datePublished":"2020-04-15T23:45:25+00:00","dateModified":"2022-02-03T17:24:26+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#primaryimage","url":"http:\/\/i.imgur.com\/iH5nnIb.gif","contentUrl":"http:\/\/i.imgur.com\/iH5nnIb.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/console-app-for-sharepoint-online-with-mfa-turned-on\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"Console App for Sharepoint Online with MFA turned on."}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/2122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=2122"}],"version-history":[{"count":4,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/2122\/revisions"}],"predecessor-version":[{"id":2129,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/2122\/revisions\/2129"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=2122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=2122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=2122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}