Skip to content
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

Upgrade from 1.9.0 to 5.80.0 #1884

Open
andreastheodosiou opened this issue Mar 11, 2024 · 4 comments
Open

Upgrade from 1.9.0 to 5.80.0 #1884

andreastheodosiou opened this issue Mar 11, 2024 · 4 comments

Comments

@andreastheodosiou
Copy link

Expected behavior

Am trying to upgrade from Microsoft Graph 1.9.0 to 5.80.0. I copied pasted the exact code from https://learn.microsoft.com/en-us/graph/sdks/create-client?tabs=java and tried to test.

Actual behavior

The last line in the code below gives me an error in Eclipse with the only solution to remove the parameters from the constructor. When removing them it gives me another error that the constructor is not visible.

Steps to reproduce the behavior

First error (before removing parameters from constructor).
The constructor GraphServiceClient(ClientSecretCredential, String[]) is undefined

When removing the parameters I get
The constructor GraphServiceClient() is not visible

Dependancies

com.microsoft.azure
msal4j
1.14.3


com.microsoft.graph
microsoft-graph
5.80.0


com.azure
azure-identity
1.3.0


com.microsoft.graph
microsoft-graph-auth
0.3.0

Code
......
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.requests.GraphServiceClient;
....
public void testEmail() {
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 String[] scopes = new String[] { "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 GraphServiceClient graphClient = new GraphServiceClient(credential, scopes);
}

@Ndiritu
Copy link
Contributor

Ndiritu commented Mar 12, 2024

Hi @andreastheodosiou, we recommend upgrading to the latest version 6.x of the SDK. Code samples on the docs are expected to work with v6.x.

@andreastheodosiou
Copy link
Author

andreastheodosiou commented Mar 17, 2024 via email

@andreastheodosiou
Copy link
Author

andreastheodosiou commented Mar 18, 2024 via email

@andreastheodosiou
Copy link
Author

andreastheodosiou commented Apr 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants