Skip to content

Commit

Permalink
Potential fix for issue 4241 (#4425)
Browse files Browse the repository at this point in the history
* Added taking over clientid from passed in connection

* Updated documentation

* Adding changelog entry

---------

Co-authored-by: Gautam Sheth <[email protected]>
  • Loading branch information
KoenZomers and gautamdsheth authored Oct 12, 2024
1 parent 836a22d commit 723897e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- `Clear-PnPRecycleBinItem` , `Move-PnPRecycleBinItem` and `Restore-PnPRecycleBinItem` cmdlets now use PnP Core SDK for processing requests. [#4393](https://github.com/pnp/powershell/pull/4393/)
- `Get-PnPSearchCrawlLog` cmdlet now shows a warning in case application permissions are used. [#4391](https://github.com/pnp/powershell/pull/4391)
- All Power Platform cmdlets no longer require an environment to be specified. If omitted, the default environment will be retrieved and used. [#4415](https://github.com/pnp/powershell/pull/4415)
- When passing in an existing connection using `-Connection` on `Connect-PnPOnline`, the clientid from the passed in connection will be used for the new connection [#4425](https://github.com/pnp/powershell/pull/4425)

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions documentation/Connect-PnPOnline.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ Accept wildcard characters: False
### -Connection
Optional connection to be reused by the new connection. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
When passed in, the ClientId/AppId used for the passed in connection will be used for the new connection. It will override any -ClientId or -AppId parameter passed in.
```yaml
Type: PnPConnection
Parameter Sets: Credentials, SharePoint ACS (Legacy) App Only, App-Only with Azure Active Directory, App-Only with Azure Active Directory using a certificate from the Windows Certificate Management Store by thumbprint, SPO Management Shell Credentials, DeviceLogin, Interactive login for Multi Factor Authentication, Environment Variable
Expand Down
7 changes: 7 additions & 0 deletions src/Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ protected void Connect(ref CancellationToken cancellationToken)
}
}

if (ParameterSpecified(nameof(Connection)))
{
// Reuse some parameters of the passed in connection
WriteVerbose("Reusing some of the connection parameters from passed in connection");
ClientId = Connection.ClientId;
}

if (AzureEnvironment == AzureEnvironment.Custom)
{
SetCustomEndpoints();
Expand Down

0 comments on commit 723897e

Please sign in to comment.