PNP.Powershell OIDC Authentication


I’ve setup the OIDC authentication as described in the documentation and I am also receiving the $accessToken after login. This is working as expected but I now tried to connect to Sharepoint Online using the PNP.Powershell module but this isn’t working as expected.

The PNP.Powershell module is a Microsoft & community created module to modify Sharepoint Online content, therefore great in combination with Powershell Universal to work with Sharepoint Online data.
The module also has a parameter to connect via Access Token:
Connect-PnPOnline -Url “” -AccessToken $token

Therefore I’ve added “All Sites Read Write” API permissions to my Powershell Universal Azure App registration but when I tried to connect to PnPOnline and use Get-PnPList I received an “unauthorized” error.

I’ve run another test by creating an App Registration as stated in their documentation (Authentication | PnP PowerShell). Once I did this I fetched an Access Token and I could use it as expected e.g. fetching lists using the Get-PnPList cmdlet was successful.

I can’t tell what’s the difference on the tokens received by PNP.Powershell App and the Powershell Universal App but it works with the first one and does not with the latter.

Any ideas?

I know the question is quite specific for this module but I thought I’ll try my luck here because knowning how to utilizing the module might be useful for others too.

Product: PowerShell Universal
Version: 1.5.14