Forum Discussion
Connect-PnPOnline -UseWebLogin fails, login window disappears
- AnonymousAug 02, 2019Have you tried amending your hosts file?
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?
Does it still happen after clearing all web cache, cookies etc?
- KenStewartAug 05, 2019Brass Contributor
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.PnPClientContextNote 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.
- AnonymousAug 05, 2019Interesting. Which version of the PnP cmdlets are you using?
- KenStewartAug 05, 2019Brass Contributor
When I say just, I mean just a few days ago. This is my first foray into SP online applets.
- KenStewartAug 02, 2019Brass Contributor
Good thoughts, haven't tried yet. Need to get some work done for a while. Will try later and let you know.
Thanks again.