use of com.microsoft.graph.authentication.TokenCredentialAuthProvider in project msgraph-sdk-java-core by microsoftgraph.
the class DeviceCodeFlowMain method main.
public static void main(String[] args) throws Exception {
final DeviceCodeCredential deviceCodeCred = new DeviceCodeCredentialBuilder().clientId(CLIENT_ID).challengeConsumer(challenge -> System.out.println(challenge.getMessage())).build();
final TokenCredentialAuthProvider tokenCredAuthProvider = new TokenCredentialAuthProvider(SCOPES, deviceCodeCred);
final OkHttpClient httpClient = HttpClients.createDefault(tokenCredAuthProvider);
final Request request = new Request.Builder().url("https://graph.microsoft.com/v1.0/me/").build();
httpClient.newCall(request).enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) throws IOException {
System.out.println(response.body().string());
}
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
});
}
Aggregations