Skip to content

[BUG] Execution fails after 2h with "Unauthorized" #5031

@PatrickSpies

Description

@PatrickSpies

Reporting an Issue or Missing Feature

We´re running a script working on many list-items. Connection is established with Connect-PnPOnline -Url "$env:O365_URL" -AzureADWorkloadIdentity as we´re using workload-identity. The provided token-file contains a token valid for 6 hours.

After 2 hours any cmdlet fails with

Unexpected response from the server. The content type of the response is "". The status code is "Unauthorized".

I tried to explicitly reconnect (Disconnect-PnPOnline and Connect-PnPOnline again) after 1 hour, but the error keeps occouring 2 hours after the initial Connect-PnPOnline.

Expected behavior

As long as the provided workload-identity-token is valid, cmdlets should keep working.

Actual behavior

2 hours after initial Connect-PnPOnline any Cmdlet fails with

Unexpected response from the server. The content type of the response is "". The status code is "Unauthorized".

Steps to reproduce behavior

Connect-PnPOnline -Url "$env:O365_URL" -AzureADWorkloadIdentity

$List = Get-PnPList -Identity $env:LIST_TITLE

$Items = Get-PnPListItem -List $List.Id.Guid -Query "<<redacted>>"

$Items | ForEach-Object {

# Working with Item ($_) via different cmdlts (e.g. Set-PnPListItem, Get-PnPProperty, Set-PnPListItemPermission)
# Running without any issues for 2 hours, starts failing afterwards

}

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

v3.1.0

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

Container-image based on mcr.microsoft.com/powershell:alpine-3.20, running at AKS with workload-identity enabled.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions