Why does GraphServiceClient say I'm using okhttp3.Request eventhough I don't even import it?
I'm trying to get the access token using Microsoft Graph SDK, this is the code:
import com.azure.identity.InteractiveBrowserCredential;
import com.azure.identity.InteractiveBrowserCredentialBuilder;
import com.microsoft.graph.authentication.TokenCredentialAuthProvider;
import com.microsoft.graph.models.User;
import com.microsoft.graph.models.Request;
import com.microsoft.graph.requests.GraphServiceClient;
import java.util.Arrays;
import java.util.List;
public class Main {
static final String clientId = "XXX-XXX-XXX";
static final String tenantId = "consumers";
static final String redirectUrl = "http://localhost:8080";
static final List<String> scopes = Arrays.asList("User.Read");
public static void main(String[] args) {
final InteractiveBrowserCredential credential = new InteractiveBrowserCredentialBuilder() .clientId(clientId).tenantId(tenantId).redirectUrl(redirectUrl).build();
final TokenCredentialAuthProvider authProvider = new TokenCredentialAuthProvider(
scopes, credential);
GraphServiceClient<Request> graphClient =
GraphServiceClient
.builder()
.authenticationProvider(authProvider)
.buildClient();
User me = graphClient.me().buildRequest().get();
// Print the user's display name
if (me != null) {
System.out.println(me.displayName);
}
}
}
as you can see I don't import the okhttp3 package but the IDE keeps saying that something is wrong with GraphServiceClient<Request> graphClient = GraphServiceClient .builder() .authenticationProvider(authProvider) .buildClient();
Required type: GraphServiceClient <com.microsoft.graph.models.Request>
Provided: GraphServiceClient <okhttp3.Request>
I know that Microsoft SDK uses okhttp3 to make requests but I don't know where the conflict is. Here's the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>ms</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>5.77.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.aad</groupId>
<artifactId>adal4j</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.13.5</version>
</dependency>
</dependencies>
</project>
I did try to use other versions of the dependencies but the results are the same