pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
985 stars 665 forks source link

How to reset "Connect-PnPOnline –Url https://xxx.sharepoint.com/ -UseWebLogin"? #1656

Open Leetcore opened 5 years ago

Leetcore commented 5 years ago

Reporting an Issue or Missing Feature

I want to connect with:

Connect-PnPOnline –Url https://xxx.sharepoint.com/ -UseWebLogin

But the user has not the needed rights. Is there any way to reset this and enter login credentials in the web form again?

Expected behavior

Maybe a -resetCredentials param that deletes auth cookies?

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

SharePointPnPPowerShellOnline 2.28.1807.0

How did you install the PnP-PowerShell Cmdlets?

MikeMorawski commented 5 years ago

For me I simply exit out of the powershell instance and reopen and run the last command. Seems to clear out the cached login.

PedroMordeP commented 5 years ago

I also have this issue when i have one credential and is saved using web login. The -UseWebLogin should have also the -ClearTokenCache used with the -SPOManagementShell to clear and give the option to choose another account.

Leetcore commented 5 years ago

I found out that it is using the Internet Explorer cache and cookies. If you clear them, the web login asks again for user.

stevish-com commented 5 years ago

Because my windows user is the same (on my work machine) as my normal login, it forces me to always log in with that. I also have an admin user, but I never get the option to log in with that. Tried logging out and clearing cache in Internet explorer and Edge, but it didn't work. Any other ideas to force a new login? I think with the Connect-SPOnline you can enter just a username so that when it asks for you to log in, it's as that user. Is there a way to do that in PnPOnline with -UseWebLogin on? Or a way to use the default browser instead of IE?

CPritch commented 5 years ago

I can confirm the same issue as @stevish-com; my UPN is an external user on their 365 tenancy and I have access to an admin account for this task. The only way I can access is to run the commands on a different UPN as it seems to not pick up the implicit flow stuff then. There needs to be an option to force login on MFA enabled accounts.

tarjeieo commented 5 years ago

I've struggled with the same for a while... It looks like instead of using UseWebLogin, the parameter SPOManagementShell is almost always working. This does not allow you to pick from "cached" logins though, but I guess that's kind of the point.

stevish-com commented 5 years ago

By jove! @tarjeieo, you've nailed it! I just logged in as my admin account and it worked beautifully! Like you said, no cache, which is exactly the point! Thanks so much!

vayinapurapu commented 3 years ago

I have tried deleting the IE chrome Cache and it still defaults to my current login. Any ways to make sure that -useWebLogin prompts for creds?

vayinapurapu commented 3 years ago

I have found a work around for this issue. Somehow my powershell is taking my login credentials. In order to connect to admin portal using pnp i tried to connect to Dev Tenant, and then it showed message 'Access Denied' sign in with different user. Then i close out that window and tried using admin account again to connect to SharePoint admin tenant. Thank you for reading this.

stryqx commented 3 years ago

-UseWebLogin needs an additional parameter to allow the use of explicit credentials, rather than using the stored credentials associated with the logged on user account. The workaround is to run a Powershell session under a user account that has no stored credentials.

PedroMordeP commented 3 years ago

One of the issues also that i encountered is if you are using on Windows an account linked to your Work or School account, PnP will use those credentials to login and there's no way to choose another one.

The solution will be what @stryqx said :(