powershell icon indicating copy to clipboard operation
powershell copied to clipboard

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

Open sanek112r opened this issue 9 months ago • 5 comments

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

sanek112r avatar Apr 29 '24 19:04 sanek112r

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

gautamdsheth avatar Jun 18 '24 18:06 gautamdsheth

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

sanek112r avatar Jun 30 '24 17:06 sanek112r

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

ouali-ls2 avatar Jul 11 '24 15:07 ouali-ls2

+1

jflieben avatar Aug 01 '24 18:08 jflieben

+1, any update on this issue?

Burchynskyi avatar Sep 12 '24 15:09 Burchynskyi