AzureAD / MSAL.PS

MIT License
159 stars 29 forks source link

Error: Get-MsalToken : Cannot convert 'System.Object[]' to the type 'System.Exception' required by parameter 'Exception'. Specified method is not supported. #53

Open markdomansky opened 2 years ago

markdomansky commented 2 years ago

I am starting to get these errors occasionally. I use the disk cache, but clearing the disk cache does not resolve it.

PS> $token = Get-GraphDelegatedToken -ApplicationID $clientid -Verbose:$false
Get-MsalToken : Cannot convert 'System.Object[]' to the type 'System.Exception' required by parameter 'Exception'. Specified method is not supported.
At C:\ps\data\local\modules\msal.ps\4.37.0.0\Get-MsalToken.ps1:293 char:49
+ ... ionResult = Get-MsalToken -Silent -PublicClientApplication $PublicCli ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-MsalToken], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Get-MsalToken

I've been able to temporarily work around this issue by changing this line 299 on get-msaltoken from:

catch [Microsoft.Identity.Client.MsalUiRequiredException] {

to:

catch  {

I know that probably isn't a valid fix, but it at least gets me going and might help others. I haven't noticed any negative side-effects.