Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Microsoft.Graph and PnP.PowerShell conflict (Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider') #3811

Closed
kpinel opened this issue Mar 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kpinel
Copy link

kpinel commented Mar 6, 2024

Notice

Describe the bug
When loading the latest versions of PnP.PowerShell and Graph and running any Graph query, we get the following error
Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core

To Reproduce
Steps to reproduce the behavior:

  1. Import-module pnp.PowerShell
  2. Connect-mggraph
  3. Note error Connect-MgGraph: InteractiveBrowserCredential authentication failed: Could not load type 'Microsoft.Identity.Client.BaseAbstractApplicationBuilder'1' from assembly 'Microsoft.Identity.Client, Version=4.50.0.0, Culture=neutral, PublicKeyToken

Load graph first

  1. Connect-MgGraph
  2. Connect

Expected behavior
Expect both modules to be able to work together

Debug Output

Get-MgUser -UserId [email protected] -Debug
DEBUG: [CmdletBeginProcessing]: - Get-MgUser begin processing with parameterSet 'Get'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, MailboxSettings.Read, openid, Organization.Read.All, profile, Team.Create, Team.ReadBasic.All, TeamMember.ReadWrite.All, TeamsActivity.Read, User.Read, User.Read.All, User.ReadWrite.All, UserAuthenticationMethod.Read.All, UserAuthenticationMethod.ReadWrite.All, email].
DEBUG: [CmdletException]: Received exception with message 'TypeLoadException - Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. :    at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient()
   at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)
   at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)
   at Microsoft.Graph.PowerShell.Cmdlets.GetMgUser_Get.ProcessRecordAsync()'
Get-MgUser_Get: Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
DEBUG: [CmdletEndProcessing]: - Get-MgUser end processing.

Module Version

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.15.0                Microsoft.Graph.Authentication      Core,Desk {Connect-MgGraph, Disconnect-MgGraph, Get-MgContext, Invoke-MgGraphRequest…}
Manifest   2.4.0                 PnP.PowerShell                      {Add-PnPAlert, Add-PnPApp, Add-PnPApplicationCustomizer, Add-PnPAvailableSiteClassification…}

Environment Data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context
Also reporting the same bug in MSGraph just in case.

Workaround
Using the latest modules
Connect-MgGraph
Perform graph command
Connect-PnPOnline

Commands from both modules seem to work after this

Doesn't seem to impact PnP.PowerShell 1.12.0 on PS 5.1. We have an older automation server that doesn't work well with PS7 and Active Directory modules

@kpinel kpinel added the bug Something isn't working label Mar 6, 2024
@gautamdsheth
Copy link
Collaborator

Duplicate of #3637

@gautamdsheth gautamdsheth marked this as a duplicate of #3637 Mar 6, 2024
@gautamdsheth gautamdsheth closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants