@@ -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