pnp / powershell

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

[FEATURE] Connect-PnPOnline with AcessToken to support multiple tokens #3925

Open sanek112r opened 4 months ago

sanek112r commented 4 months ago

Is your feature request related to a problem? Please describe. We are connecting to PnP using the access token, and it works for most of cases. However some PnP commands are switching the access tokens dynamically within the single cmdlet, for example, Get-PnPFolderSharingLink. When I captured the web requests issued by this cmdlet, I found that it gets some info from SharePoint endpoints and some from Graph beta. Obviously this scenario can not be supported with a single access token.

Describe the solution you'd like I would like to specify multiple tokens, each one for certain audience. E.g. in my scenario, I would specify both SharePoint and Graph tokens. Then I would expect that internally PnP module will figure out which access token to use.

I think this syntax will work just fine Connect-PnPOnline -AccessTokens []

This signature will make it similar to how MicrosoftTeams handles similar scenario.

Describe alternatives you've considered We have quite unique scenario, where access tokens is the best solution for us from the security standpoint. So unfortunately there seem to be no alternatives.

Additional context N/A

gautamdsheth commented 3 months ago

@sanek112r - we do things a bit differently here. Maybe the below approach can help you ?

$conn1 = connect-pnponline -Identity <siteUrl> -AccessToken $ac1 -ReturnConnection
$conn2 = connect-pnponline -Identity <siteUrl-2> -AccessToken $ac2 -ReturnConnection

You can then reuse the $conn1 or $conn2 in the script later on. Does that make sense ?

sanek112r commented 2 months ago

@gautamdsheth interesting idea, thanks. The issue here is that multiple resources and tokens can be used in scope of single cmdlet execution (e.g. Get-PnPFolderSharingLink mentioned above). Hence context should be switching inside cmdlet execution, which is not possible to implement with existing api.

ouali-ls2 commented 2 months ago

+1, we have exactly the same requirement , any update ?

jflieben commented 1 month ago

+1

Burchynskyi commented 1 week ago

+1, any update on this issue?