I am using the Microsoft Graph api to send and get mails in my Spring Boot Application,
I had used the dependencies of graph api like
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<!-- This dependency is only needed if you are using the TokenCrendentialAuthProvider -->
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.2.5</version>
</dependency>
In code my imports are
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.authentication.TokenCredentialAuthProvider;
import com.microsoft.graph.models.BodyType;
import com.microsoft.graph.models.EmailAddress;
import com.microsoft.graph.models.ItemBody;
import com.microsoft.graph.models.Message;
import com.microsoft.graph.models.Recipient;
import com.microsoft.graph.models.UserSendMailParameterSet;
import com.microsoft.graph.requests.GraphServiceClient;
import com.microsoft.graph.requests.MessageCollectionPage;
Error coming in code at
ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(CLIENT_ID)
.clientSecret(CLIENT_SECRET).tenantId(TENANT_GUID).build();
TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(SCOPES, clientSecretCredential);
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( tokenCredentialAuthProvider ).buildClient();
MessageCollectionPage messagesPage = graphClient.me().messages()
.buildRequest()
.select("Sender,Subject")
.top(10)
.get();
I am getting a error like this in code.
(DirectJDKLog.java:175) - Servlet.service() for servlet [dispatcherServlet] in context with path [/ldesk] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.azure.identity.implementation.IdentityClient] with root cause
java.lang.NoClassDefFoundError: Could not initialize class com.azure.identity.implementation.IdentityClient
at com.azure.identity.implementation.IdentityClientBuilder.build(IdentityClientBuilder.java:113) ~[azure-identity-1.2.5.jar:?]
at com.azure.identity.ClientSecretCredential.<init>(ClientSecretCredential.java:50) ~[azure-identity-1.2.5.jar:?]
at com.azure.identity.ClientSecretCredentialBuilder.build(ClientSecretCredentialBuilder.java:62) ~[azure-identity-1.2.5.jar:?]