Skip to content

Commit b88d766

Browse files
committed
- migrates test provider to v2 endpoint
1 parent efab2bd commit b88d766

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/main/java/com/microsoft/graph/core/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ private Constants() {
2828
public static final String APPID = "app-id";
2929
public static final String USERNAME = "[email protected]";
3030
public static final String PASSWORD = "password";
31+
public static final String TENANTID = "tenantid";
32+
public static final String CLIENTSECRET = "clientsecret";
3133
public static final String VERSION_NAME = "2.0.0";
3234
}

src/test/java/com/microsoft/graph/functional/TestBase.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ public class TestBase {
2121
private String clientId;
2222
private String username;
2323
private String password;
24+
private String clientSecret;
2425
// Don't use password grant in your apps. Only use for legacy solutions and automated testing.
2526
private String grantType = "password";
26-
private String tokenEndpoint = "https://login.microsoftonline.com/common/oauth2/token";
27-
private String resourceId = "https%3A%2F%2Fgraph.microsoft.com%2F";
27+
private String tokenEndpoint = "https://login.microsoftonline.com/"+ Constants.TENANTID +"/oauth2/v2.0/token";
28+
private String resourceId = "https%3A%2F%2Fgraph.microsoft.com%2F.default";
2829
private String accessToken = null;
2930

3031
protected IGraphServiceClient graphClient = null;
@@ -34,6 +35,7 @@ public TestBase()
3435
clientId = Constants.APPID;
3536
username = Constants.USERNAME;
3637
password = Constants.PASSWORD;
38+
clientSecret = Constants.CLIENTSECRET;
3739

3840
GetAuthenticatedClient();
3941
}
@@ -77,12 +79,13 @@ private String GetAccessToken()
7779
conn.setInstanceFollowRedirects(false);
7880
conn.connect();
7981
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
80-
String payload = String.format("grant_type=%1$s&resource=%2$s&client_id=%3$s&username=%4$s&password=%5$s",
82+
String payload = String.format("grant_type=%1$s&scope=%2$s&client_id=%3$s&username=%4$s&password=%5$s&client_secret=%6$s",
8183
grantType,
8284
resourceId,
8385
clientId,
8486
username,
85-
password);
87+
password,
88+
clientSecret);
8689
writer.write(payload);
8790
writer.close();
8891
try {

0 commit comments

Comments
 (0)