com.azure.identity.ClientSecretCredential - Azure Identity => ERROR in getToken()

Karunaker Reddy V 5 Reputation points
2023-11-28T13:21:35.9466667+00:00

I'm trying to use Microsoft Azure Graph API to access groups, apps, users, auditlog data.

I have valid clientID, client secret, tenantid and consent granted scopes and I've tried accessing the same API's from postman and those are working properly but when I use Graph SDK fro Java from microsoft(Github) with below code (which is a sample from microsoft documentation)

final String clientId = "YOUR_CLIENT_ID";
final String tenantId = "YOUR_TENANT_ID";
final String clientSecret = "YOUR_CLIENT_SECRET";

// The client credentials flow requires that you request the
// /.default scope, and pre-configure your permissions on the
// app registration in Azure. An administrator must grant consent
// to those permissions beforehand.
final List<String> scopes = Arrays.asList("https://graph.microsoft.com/.default");

final ClientSecretCredential credential = new ClientSecretCredentialBuilder()
    .clientId(clientId).tenantId(tenantId).clientSecret(clientSecret).build();

if (null == scopes || null == credential) {
    throw new Exception("Unexpected error");
}
final TokenCredentialAuthProvider authProvider = new TokenCredentialAuthProvider(
    scopes, credential);

final GraphServiceClient<Request> graphClient = GraphServiceClient.builder()
    .authenticationProvider(authProvider).buildClient();

/// below is the line I've wrote to get groups for the given tenant/client
GroupCollectionPage groupList = graphClient.groups().buildRequest().get();


on executing the above code getting below error

[ForkJoinPool.commonPool-worker-19] ERROR com.azure.identity.ClientSecretCredential - Azure Identity => ERROR in getToken() call for scopes [https://graph.microsoft.com/.default]: Could not initialize class reactor.netty.http.client.HttpClientSecure

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,421 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Brandon Liu 0 Reputation points
    2023-12-01T05:42:44.67+00:00

    Dude, have you solved your problem? I have encountered the same problem as you