Creating GraphServiceClient for a Client credentials provider, using a client secret not working
I'm migrating my project from using HTTP Direct calls to MSGraph endpoints to use MS Graph Java SDK 6.x
When using standard, recommended code for creating MsGraphClient (https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=java#client-credentials-provider) , I'm getting errors related to host no found. in local developement and in Server we get this error:
"java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalServiceException: AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '717ab8d8-27a7-4b6e-8664-497e8318eab8'. Trace ID: 3108f99c-b17b-46f6-a252-6f88fa5e4500 Correlation ID: d324448f-91b2-416f-ad0c-1251edadc9a0 Timestamp: 2025-03-14 07:12:38Z at com.azure.identity.implementation.IdentitySyncClient.authenticateWithConfidentialClient(IdentitySyncClient.java:142) at com.azure.identity.ClientSecretCredential.getTokenSync(ClientSecretCredential.java:136) at com.microsoft.kiota.authentication.AzureIdentityAccessTokenProvider.getAuthorizationToken(AzureIdentityAccessTokenProvider.java:167) at com.microsoft.kiota.authentication.BaseBearerTokenAuthenticationProvider.authenticateRequest(BaseBearerTokenAuthenticationProvider.java:46) at com.microsoft.kiota.http.OkHttpRequestAdapter.getHttpResponseMessage(OkHttpRequestAdapter.java:741) at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:302) at com.microsoft.graph.users.item.UserItemRequestBuilder.get(UserItemRequestBuilder.java:761) at com.microsoft.graph.users.item.UserItemRequestBuilder.get(UserItemRequestBuilder.java:747)
I don't have any problem to get AccessTOken in my current code, via HTTP, using my app credentials (client ID, client secrert, tenant), so I don't know why complaint about secretID is related. see snippet code below
String URLToken = "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/token";
URL url = new URL(URLToken);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
Map<String, String> parameters = new HashMap<>();
parameters.put("tenant", tenant);
parameters.put("client_id", general.getClientId());
parameters.put("scope", "https://graph.microsoft.com/.default");
parameters.put("client_secret", general.getClientSecret());
parameters.put("grant_type", "client_credentials");
Which detail I'm missing in my code using azure-indentity? I'm using Entra ID free version, I only have my app registered.