-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
acquireTokenByClientCredential broken for clientCertificate #7082
Comments
I have the same problem |
Hi, this started happening to me and my team as well for newer builds, as a workaround we had to downgrade to version 2.6.4 |
get same error on version 2.6.* |
@KarishmaGhiya - please see this bug. I recommend you don't take dependency on MSAL 2.8 |
@ericcan @aleclair-KoAi @joaquingomez-tc @wenytang-ms I can only reproduce this issue when thumbprint and privateKey are both empty strings. Can you all doublecheck your thumbprint and privateKey values and let me know if they're empty strings or not? |
Neither the privateKey or thumbprint are empty strings in my case. The exact same calls do work with 2.7. Not sure if it's helpful, but this is some call stack info that leads to the error (it's from a bundle, so the line numbers don't mean much but I could get you some data on the specific lines if it helps track this down).
|
Sure, a specific line would help. I think the regression was introduced in this PR: Client Assertion implementation now accepts an async callback as well as a string argument |
17286 is: 17572 is: |
… as a string argument (#7014) Client assertion can currently be provided by a developer as a string. This PR allows a developer to provide an async callback (which will resolve to a string) as the client assertion. The client assertion initialization has been removed from ConfidentialClient's constructor and is now initialized inside of buildOauthClientConfiguration, called during every acquireToken call. Note: Applied Boy-Scout-Rule on UsernamePasswordClient.spec.ts. Only the last test in the file is relevant for this review. Now this test file is up-to-date and mirrors ClientCredentialsClient.spec.ts and OnBehalfOfClient.spec.ts.
See this comment for a possible place that might be causing the certificate to get lost. |
@Robbie-Microsoft we use msal-node to get graph token
and get such error, i'm not sure what should i update the code to query graph and get 200 response. |
@wenytang-ms - this is probably unrelated. A public client application does not need a secret or a certificate. UsernamePassword exists for both public client and for confidential client. It is disabled by default for public client. Go to the portal and enable it. But! Please realize that UsernamePassword flow is extremely insecure and should be avoided. We only recommend using it in tests, to test web apis. Public Client (CLI, desktop apps) should use interactive authentication. |
@bgavrilMS indeed! |
@wenytang-ms - I think this is just a setting in the app registration. Please send me an email to discuss further. |
Excellent, thanks for this @ericcan . I will be working on this today. |
It works with At first time, I thought it's Azure Entra ID Application configuration problem. As my checking the error happens exactly from 2.6.5 |
Terrific. I did do a local fix that works and would be happy to share it, but wasn't confident that it was consistent with all the cases. Let me know if there is anything that would be helpful. |
Sure, please email the fix to Bogdan and he will forward it to me. In the meantime, I'm able to reproduce this now. |
I was able to reproduce the issue via tinkering with our unit tests and developed a fix via the linked PR. Unit tests are needed before review + merging into our dev branch. I'll be publishing a new version of msal-node with this fix either today or tomorrow. |
…ient assertion (#7088) Fixes [acquireTokenByClientCredential broken for clientCertificate #7082](#7082) Applied boy-scout-rule to `ConfidentialClientApplication.spec.ts` (contains unit tests). I've been waiting for a good opportunity to do this. The ConfidentialClientApplication tests are now in line with the other test files: All Managed Identity sources, ClientCredentialClient, OnBehalfOfClient and UsernamePasswordClient. Co-authored-by: @ericcan
Fixed in v2.8.1, which is now available to install. |
Core Library
MSAL Node (@azure/msal-node)
Core Library Version
2.8.0
Wrapper Library
Not Applicable
Wrapper Library Version
n/a
Public or Confidential Client?
Confidential
Description
I upgraded to the latest version (2.8 from 2.7) and my call to acquireTokenByClientCredential fails now.
Error Message
{
"errorCode": "invalid_client",
"errorMessage": "7000216 - [2024-05-07 15:55:13Z]: AADSTS7000216: 'client_assertion', 'client_secret' or 'request' is required for the 'client_credentials' grant type. Trace ID: d1a0baab-1cf3-4a20-a263-605f65ceb200 Correlation ID: a93c308b-63ff-4880-8d07-383a27828034 Timestamp: 2024-05-07 15:55:13Z - Correlation ID: a93c308b-63ff-4880-8d07-383a27828034 - Trace ID: d1a0baab-1cf3-4a20-a263-605f65ceb200",
"subError": "",
"name": "ServerError",
"errorNo": 7000216,
"correlationId": "2bedce44-4ef7-4752-abb9-39cfe913cea3"
}
MSAL Logs
No response
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Run the code above
Expected Behavior
A token is returned
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome
Regression
@azure/msal-node @2.7.0
Source
External (Customer)
The text was updated successfully, but these errors were encountered: