SOLVED
Home

Connect-PnPOnline -UseWebLogin fails, login window disappears

%3CLINGO-SUB%20id%3D%22lingo-sub-784915%22%20slang%3D%22en-US%22%3EConnect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-784915%22%20slang%3D%22en-US%22%3E%3CP%3EI%20downloaded%20the%20latest%20version%20of%26nbsp%3BPnP%20PowerShell%20today%20but%20have%20had%20no%20success%20with%26nbsp%3BConnect-PnPOnline%20(no%20problem%20using%26nbsp%3BConnect-SPOService).%20I%20get%20the%20dreaded%20error%20%22For%20security%20reasons%20DTD%20is%20prohibited%20in%20this%20XML%20document.%22%20I've%20researched%20this%20and%20tried%20all%20the%20fixes%2C%20like%20disabling%20IPv6%20and%20pointing%20to%20Google%20DNS%20servers.%20I've%20also%20tried%20Windows%20and%20Generic%20Credentials%2C%20but%20these%20don't%20avoid%20the%20online%20authentication%20and%20get%20the%20same%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20most%20promising%20work-around%20appeared%20to%20be%20the%26nbsp%3B-UseWebLogin%20option%2C%20but%20the%20window%20disappears.%20It's%20only%20up%20for%20a%20fraction%20of%20a%20second%2C%20which%20isn't%20long%20enough%20for%20me%20to%20read%20the%20single%20line%20of%20text%20there.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20solve%20the%20case%20of%20the%20missing%26nbsp%3B-UseWebLogin%20window%3F%20This%20is%20an%20Office%20365%20E3%20tenant.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-784915%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785169%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785169%22%20slang%3D%22en-US%22%3EHave%20you%20tried%20amending%20your%20hosts%20file%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785558%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785558%22%20slang%3D%22en-US%22%3E%3CP%3EYou're%20a%20lifesaver%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F234199%22%20target%3D%22_blank%22%3E%40Steve%20Johnson%3C%2FA%3E.%20I%20saw%20that%20fix%20from%26nbsp%3BPaul%20Ryan%20online%2C%20but%20I%20neglected%20to%20try%20it.%20So%20in%20response%20to%20your%20post%2C%20I%20added%20this%20entry%20to%20my%20hosts%20file%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E127.0.0.1%20msoid.summitservices.us.com%20%23%20fix%20PnP%20connect%20problem%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ewhere%20our%20domain%20is%26nbsp%3Bsummitservices.us.com.%20I%20connected%20first%20time%20without%20an%20authentication%20dialog%20(since%20I'd%20already%20set%20up%20Windows%20Credentials).%20I%20ran%20a%20few%20other%20applets%20as%20a%20quick%20test%2C%20all%20successful.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20definitely%20solved%20my%20main%20problem%2C%20but%20I%20tried%20to%20connect%20again%20using%20-UseWebLogin%20with%20the%20same%20result%3A%20quickly%20disappearing%20window.%20The%20mystery%20remains.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785571%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785571%22%20slang%3D%22en-US%22%3EHappy%20to%20help%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3E%3CBR%20%2F%3EWhen%20-UseWebLogin%20quickly%20disappears%2C%20could%20it%20be%20you%20are%20already%20authenticated.%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you%20run%20Get-PnPContext%20it%20should%20give%20you%20that%20info.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785606%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785606%22%20slang%3D%22en-US%22%3E%3CP%3ELooks%20like%20that's%20not%20exactly%20it%2C%20but%20there%20are%20more%20clues.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20opened%20a%20new%20PowerShell%20session%20and%20ran%26nbsp%3BGet-PnPContext%20just%20to%20make%20sure%20there%20was%20no%20connection%3B%20returned%20an%20error%20saying%20I%20needed%20a%20connection%20first.%20I%20ran%20connect%20again%20with%20the%20web%20option%2C%20and%20the%20window%20still%20disappears.%20However%2C%20this%20time%20I%20asked%20for%20the%20context%20again%20and%20I%20was%20authenticated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EApparently%2C%20something%20is%20bypassing%20a%20web%20dialog%20and%20trying%20a%20different%20authorization%20mechanism%2C%20which%20now%20succeeds%20because%20of%20the%20hosts%20configuration.%20To%20test%20this%2C%20I%20tried%20to%20connect%20to%20a%20different%20site%20that%20I%20hadn't%20configured%20with%20Credentials%20Manager%3B%20failed%20saying%20needed%20connection.%20Ran%20again%20with%20web%20option%2C%20window%20disappeared%2C%20but%20no%20error.%20Get-PnPContext%20then%20showed%20the%20new%20site.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInteresting%2C%20but%20still%20a%20little%20mystery%3F%20Isn't%26nbsp%3B-UseWebLogin%20supposed%20to%20bring%20up%20a%20dialog%20to%20enter%20username%20and%20password%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785619%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785619%22%20slang%3D%22en-US%22%3EIt%20is%2C%20but%20it%20sounds%20like%20it%20already%20has%20authentication%20credentials.%3CBR%20%2F%3E%3CBR%20%2F%3EDoes%20it%20still%20happen%20after%20clearing%20all%20web%20cache%2C%20cookies%20etc%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-785650%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-785650%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20thoughts%2C%20haven't%20tried%20yet.%20Need%20to%20get%20some%20work%20done%20for%20a%20while.%20Will%20try%20later%20and%20let%20you%20know.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-788002%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-788002%22%20slang%3D%22en-US%22%3E%3CP%3ESo%2C%20I%20may%20have%20taken%20a%20step%20backwards.%20After%20taking%20a%20break%20for%20a%20day%2C%20connecting%20no%20longer%20worked%20as%20smoothly%20as%20it%20did%20when%20I%20first%20modified%20the%20hosts%20file.%20I%20didn't%20change%20anything%20that%20I'm%20aware%20of%2C%20and%20I%20checked%20that%20hosts%20was%20the%20same.%20Long%20story%20short%2C%20I%20can%20connect%20but%20always%20have%20to%20add%20the%26nbsp%3B-UseWebLogin%20parameter.%26nbsp%3BGet-PnPConnection%20returns%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnectionType%20%3A%20O365%3CBR%20%2F%3EInitializationType%20%3A%20Unknown%3CBR%20%2F%3EMinimalHealthScore%20%3A%20-1%3CBR%20%2F%3ERetryCount%20%3A%2010%3CBR%20%2F%3ERetryWait%20%3A%201%3CBR%20%2F%3EPSCredential%20%3A%3CBR%20%2F%3ETelemetryClient%20%3A%20Microsoft.ApplicationInsights.TelemetryClient%3CBR%20%2F%3EUrl%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fsummitservicesus.sharepoint.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsummitservicesus.sharepoint.com%2F%3C%2FA%3E%3CBR%20%2F%3ETenantAdminUrl%20%3A%3CBR%20%2F%3EContext%20%3A%20OfficeDevPnP.Core.PnPClientContext%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENote%20ConnectionType%20is%20O365%20and%20PSCredential%20is%20null.%20When%20it%20was%20working%20smoothly%2C%20my%20recollection%20is%20that%20PSCredential%20was%20populated%2C%20though%20I%20don't%20remember%20the%20specifics.%20Regardless%2C%20I%20haven't%20been%20denied%20permission%20yet%20on%20any%20cmdlets%20I've%20run%20(mostly%20gets).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFollowing%20your%20suggestion%2C%20I%20did%20try%20clearing%20cache%20first%20then%20cookies%20and%20history.%20There%20was%20no%20apparent%20difference%20in%20behavior.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-788441%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-788441%22%20slang%3D%22en-US%22%3EInteresting.%20Which%20version%20of%20the%20PnP%20cmdlets%20are%20you%20using%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-789340%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-789340%22%20slang%3D%22en-US%22%3E%3CP%3EJust%20downloaded%26nbsp%3B3.12.1908.1%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-789365%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-789365%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20I%20say%20just%2C%20I%20mean%20just%20a%20few%20days%20ago.%20This%20is%20my%20first%20foray%20into%20SP%20online%20applets.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-797062%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-797062%22%20slang%3D%22en-US%22%3EAre%20you%20still%20using%20the%20Google%20DNS%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-797247%22%20slang%3D%22en-US%22%3ERe%3A%20Connect-PnPOnline%20-UseWebLogin%20fails%2C%20login%20window%20disappears%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-797247%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20I%20confirmed%20all%20the%20setting%20changes%20I'd%20made%20trying%20to%20fix%20the%20original%20problem%20(e.g.%2C%20hosts%2C%20IPv6%2C%20Google%20DNS%2C%20Windows%20creds%2C%20etc.)%20are%20still%20in%20place.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I downloaded the latest version of PnP PowerShell today but have had no success with Connect-PnPOnline (no problem using Connect-SPOService). I get the dreaded error "For security reasons DTD is prohibited in this XML document." I've researched this and tried all the fixes, like disabling IPv6 and pointing to Google DNS servers. I've also tried Windows and Generic Credentials, but these don't avoid the online authentication and get the same error.

 

The most promising work-around appeared to be the -UseWebLogin option, but the window disappears. It's only up for a fraction of a second, which isn't long enough for me to read the single line of text there.

 

Can anyone solve the case of the missing -UseWebLogin window? This is an Office 365 E3 tenant.

12 Replies
Highlighted
Solution
Have you tried amending your hosts file?
Highlighted

You're a lifesaver, @Deleted. I saw that fix from Paul Ryan online, but I neglected to try it. So in response to your post, I added this entry to my hosts file:

 

127.0.0.1 msoid.summitservices.us.com # fix PnP connect problem

 

where our domain is summitservices.us.com. I connected first time without an authentication dialog (since I'd already set up Windows Credentials). I ran a few other applets as a quick test, all successful.

 

You definitely solved my main problem, but I tried to connect again using -UseWebLogin with the same result: quickly disappearing window. The mystery remains.

Highlighted
Happy to help :)

When -UseWebLogin quickly disappears, could it be you are already authenticated.

If you run Get-PnPContext it should give you that info.
Highlighted

Looks like that's not exactly it, but there are more clues.

 

I opened a new PowerShell session and ran Get-PnPContext just to make sure there was no connection; returned an error saying I needed a connection first. I ran connect again with the web option, and the window still disappears. However, this time I asked for the context again and I was authenticated.

 

Apparently, something is bypassing a web dialog and trying a different authorization mechanism, which now succeeds because of the hosts configuration. To test this, I tried to connect to a different site that I hadn't configured with Credentials Manager; failed saying needed connection. Ran again with web option, window disappeared, but no error. Get-PnPContext then showed the new site.

 

Interesting, but still a little mystery? Isn't -UseWebLogin supposed to bring up a dialog to enter username and password?

Highlighted
It is, but it sounds like it already has authentication credentials.

Does it still happen after clearing all web cache, cookies etc?
Highlighted

Good thoughts, haven't tried yet. Need to get some work done for a while. Will try later and let you know.

 

Thanks again.

Highlighted

So, I may have taken a step backwards. After taking a break for a day, connecting no longer worked as smoothly as it did when I first modified the hosts file. I didn't change anything that I'm aware of, and I checked that hosts was the same. Long story short, I can connect but always have to add the -UseWebLogin parameter. Get-PnPConnection returns:

 

ConnectionType : O365
InitializationType : Unknown
MinimalHealthScore : -1
RetryCount : 10
RetryWait : 1
PSCredential :
TelemetryClient : Microsoft.ApplicationInsights.TelemetryClient
Url : https://summitservicesus.sharepoint.com/
TenantAdminUrl :
Context : OfficeDevPnP.Core.PnPClientContext

 

Note ConnectionType is O365 and PSCredential is null. When it was working smoothly, my recollection is that PSCredential was populated, though I don't remember the specifics. Regardless, I haven't been denied permission yet on any cmdlets I've run (mostly gets).

 

Following your suggestion, I did try clearing cache first then cookies and history. There was no apparent difference in behavior.

 

Highlighted
Interesting. Which version of the PnP cmdlets are you using?
Highlighted

Just downloaded 3.12.1908.1

Highlighted

When I say just, I mean just a few days ago. This is my first foray into SP online applets.

Highlighted
Are you still using the Google DNS?
Highlighted

Yes, I confirmed all the setting changes I'd made trying to fix the original problem (e.g., hosts, IPv6, Google DNS, Windows creds, etc.) are still in place.