pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
623 stars 329 forks source link

[BUG] Can't log in using app passwords #2151

Open CodePidgy opened 1 year ago

CodePidgy commented 1 year ago

Reporting an Issue or Missing Feature

The issue is that when using an app password generated on a MFA enabled account it simply says that the password is incorrect. I clearly remember this working about 2 months ago as I was I thought it was really neat that it worked. In my case I cannot use the interactive login, I have to be able to use the app passwords.

Expected behavior

Create a credential object using the app password and pass it as the -Credentials parameter to Connect-PnPOnline and have it log in successfully.

Actual behavior

Simply states that the credentials are incorrect: image

Steps to reproduce behavior

Have Office 365 account that you can create app passwords on and a SharePoint site to test with, create an app password and use the following code:

$site = <site name>
$username = <your username>
$password = <app password>
$secure_password = ConvertTo-SecureString -String $password -AsPlainText -Force
$credentials = New-Object -TypeName 'System.Management.Automation.PSCredential' -ArgumentList $username, $secure_password

Connect-PnPOnline -Url $site -Credentials $credentials

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

1.11.0

Which operating system/environment are you running PnP PowerShell on?

CallumCrowley commented 1 year ago

@Thermohalia some people have reported that there can be a delay in app passwords working after their creation and was confirmed that it's not unusual for them to take 10 minutes to start working by Microsoft staff. Your steps to reproduce would lead to this problem, since there's no step to wait after the app password creation.

aashay147 commented 1 year ago

I can reproduce this error for app passwords created several days ago

rbabruce commented 1 year ago

I can confirm that this is correct, I had a login saved in Credential Manager that worked with the Legacy version of PnP but no longer works with 1.11.0