Skip to content

Commit ed50c5a

Browse files
committed
- updates reference to credential helper as signature changed
1 parent 7f58fa7 commit ed50c5a

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

samples/deviceCodeSample/src/main/java/deviceCodeFlowMain.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import com.microsoft.graph.exceptions.AuthenticationException;
55
import com.microsoft.graph.httpcore.HttpClients;
66
import okhttp3.*;
7-
import org.json.simple.JSONObject;
8-
import org.json.simple.parser.JSONParser;
9-
import org.json.simple.parser.ParseException;
107

118
import java.io.IOException;
129
import java.util.Arrays;
@@ -29,27 +26,20 @@ public static void main(String[] args) throws AuthenticationException {
2926

3027
public static void deviceCodeFlow() throws AuthenticationException {
3128

32-
DeviceCodeCredential deviceCodeCred = new DeviceCodeCredentialBuilder()
29+
final DeviceCodeCredential deviceCodeCred = new DeviceCodeCredentialBuilder()
3330
.clientId(CLIENT_ID)
3431
.challengeConsumer(challenge -> {System.out.println(challenge.getMessage());})
3532
.build();
3633

37-
TokenCredentialAuthProvider tokenCredAuthProvider = new TokenCredentialAuthProvider(deviceCodeCred, SCOPES);
38-
OkHttpClient httpClient = HttpClients.createDefault(tokenCredAuthProvider);
34+
final TokenCredentialAuthProvider tokenCredAuthProvider = new TokenCredentialAuthProvider(SCOPES, deviceCodeCred);
35+
final OkHttpClient httpClient = HttpClients.createDefault(tokenCredAuthProvider);
3936

40-
Request request = new Request.Builder().url("https://graph.microsoft.com/v1.0/me/").build();
37+
final Request request = new Request.Builder().url("https://graph.microsoft.com/v1.0/me/").build();
4138

4239
httpClient.newCall(request).enqueue(new Callback() {
4340
@Override
4441
public void onResponse(Call call, Response response) throws IOException {
45-
JSONParser jsonParser = new JSONParser();
46-
JSONObject responseJson = null;
47-
try {
48-
responseJson = (JSONObject) jsonParser.parse(response.body().string());
49-
} catch (ParseException e) {
50-
e.printStackTrace();
51-
}
52-
System.out.println(responseJson);
42+
System.out.println(response.body().string());
5343
}
5444

5545
@Override

0 commit comments

Comments
 (0)