AzureAD / MSAL.PS

MIT License
159 stars 29 forks source link

Error on acquiring token with certificate #3

Closed AlexSen closed 4 years ago

AlexSen commented 4 years ago

Trying to get Token by using certificate (with client id/secret works well.

$ConfidentialClientOptions = New-Object Microsoft.Identity.Client.ConfidentialClientApplicationOptions -Property @{ ClientId = $MSALRequestData.clientID; TenantId = $MSALRequestData.TenantID }
$MsalClientApplication = $ConfidentialClientOptions | Get-MsalClientApplication -ClientCertificate $MSALRequestData.Certificate
$MSALToken = $MsalClientApplication | Get-MsalToken -Scope $MSALRequestData.Scope

And here is error:

Exception calling "GetResult" with "0" argument(s): "Keyset does not exist
"
At C:\Program Files\WindowsPowerShell\Modules\MSAL.PS\4.5.1.1\Get-MsalToken.ps1:288 char:13
+             $AuthenticationResult = $AquireTokenParameters.ExecuteAsy ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CryptographicException
AlexSen commented 4 years ago

Issue solved. My fault. Have not imported certificate into USER storage.