Skip to content

Instantly share code, notes, and snippets.

@maisarissi
Created December 12, 2023 14:51
Show Gist options
  • Save maisarissi/b11ffd8fbb39017e9a924cabba10db5c to your computer and use it in GitHub Desktop.
Save maisarissi/b11ffd8fbb39017e9a924cabba10db5c to your computer and use it in GitHub Desktop.
microsoftgraph-java-v6-v1-beta-clients
DeviceCodeCredential deviceCodeCredential = new DeviceCodeCredentialBuilder()
.clientId(clientId)
.tenantId(tenantId)
.challengeConsumer(challenge -> System.out.println(challenge.getMessage()))
.build();
//create a client for calling v1.0 endpoint
com.microsoft.graph.serviceclient.GraphServiceClient graphClient =
new com.microsoft.graph.serviceclient.GraphServiceClient(
deviceCodeCredential,
graphUserScopes);
com.microsoft.graph.models.User me = graphClient.me().get();
//create a client for calling beta endpoint
com.microsoft.graph.beta.serviceclient.GraphServiceClient betaGraphClient =
new com.microsoft.graph.beta.serviceclient.GraphServiceClient(
deviceCodeCredential,
graphUserScopes);
com.microsoft.graph.beta.models.User meBeta = betaGraphClient.me().get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment