powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Can't log in using app passwords

Open CodePidgy opened this issue 2 years ago • 3 comments

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?

  • [x] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

CodePidgy avatar Jul 14 '22 21:07 CodePidgy

@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.

CallumCrowley avatar Jul 28 '22 12:07 CallumCrowley

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

aashay147 avatar Aug 19 '22 14:08 aashay147

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

rbabruce avatar Oct 19 '22 12:10 rbabruce