Skip to content

Commit

Permalink
Two-round auth implemented
Browse files Browse the repository at this point in the history
Google API changes again. The auth token which didn't have a ttl for
years now has it. Requesting a token a second time using the information
from the first request seems to produce a more durable token.
  • Loading branch information
yeriomin committed Oct 31, 2017
1 parent 6544937 commit 7517d9e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ protected Map<String, String> getDefaultLoginParams(String email, String passwor
params.put("lang", this.locale.getLanguage().toLowerCase());
params.put("sdk_version", String.valueOf(this.deviceInfoProvider.getSdkVersion()));
params.put("client_sig", "38918a453d07199354f8b19af05ec6562ced5788");
params.put("callerSig", "38918a453d07199354f8b19af05ec6562ced5788");
return params;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

public class GooglePlayAPITest {

// private static final String EMAIL = "yalp.store.user.one@gmail.com";
private static final String EMAIL = "konstantin.razdolbaev@gmail.com";
private static final String PASSWORD = "TemporaryPassword!";
private static final String GSFID = "3f1abe856b0fa7fd";
// private static final String TOKEN = "JAXCN65HwzmJg1fKq4Q3k6qY3LXu0yn7__9OOxEI_FRW4Ch90QMHiyTtCoLNZG1UMP_xlA.";
private static final String TOKEN = "jwSyrOU2RHDv2d82095MoHKOUHhO9KxBbkAoLCMkCKWqB9RUHbvq8VIWufBJcxwRn3_DGQ.";

private GooglePlayAPI api;
Expand Down Expand Up @@ -80,10 +78,10 @@ public void getToken() throws Exception {
GooglePlayAPI api = initApi();
api.setToken(null);
String token = api.generateToken(EMAIL, PASSWORD);
Assert.assertEquals("TgSyrOQWSodzTLUtSuMebIW5k1XUvhsDE3gVcf-vnL8q9qT_oofA6ygYpE4m6sSi1UrCSQ.", token);
Assert.assertEquals("VgXBOjtk7TAASCefEdBRoow60YoyEYSqliUOaaiWkFKmWKZOUK-iXb1UgA184sTRpCVrKg.", token);

List<Request> requests = ((MockOkHttpClientAdapter) api.getClient()).getRequests();
Assert.assertEquals(1, requests.size());
Assert.assertEquals(2, requests.size());

Request request = requests.get(0);
Assert.assertEquals(1, request.url().pathSegments().size());
Expand All @@ -97,6 +95,18 @@ public void getToken() throws Exception {
Assert.assertEquals("22", vars.get("sdk_version"));
Assert.assertEquals("androidmarket", vars.get("service"));
Assert.assertEquals("com.android.vending", vars.get("app"));

Request request2 = requests.get(1);
Assert.assertEquals(1, request2.url().pathSegments().size());
Assert.assertEquals("auth", request2.url().pathSegments().get(0));
Map<String, String> vars2 = MockOkHttpClientAdapter.parseQueryString(MockOkHttpClientAdapter.getBodyBytes(request2));
for (String key: vars2.keySet()) {
System.out.println(key + " = " + vars2.get(key));
}
Assert.assertEquals(17, vars2.size());
Assert.assertFalse(vars2.containsKey("Email"));
Assert.assertFalse(vars2.containsKey("EncryptedPasswd"));
Assert.assertEquals("oauth2rt_1/Dk-zYrF6YiQ_94QcJGIkTmu8f7QLbAeIH-whs3LoxFQ", vars2.get("Token"));
}

@Test
Expand Down
7 changes: 7 additions & 0 deletions src/test/resources/request.auth.293039241.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SID=VgXBOoMgJGr9fKl6XpNLQzcFts2SVbeFSMmFu5QqVfNtWvJaOGhFxzmFMwIDqRoGZJxTaQ.
LSID=VgXBOkVzoiloIjsE65L2Vm5ugL0flz6Mn6EhdXNhK8tPACdvapdjAcdxfOnPiakoPWym-A.
Auth=VgXBOjtk7TAASCefEdBRoow60YoyEYSqliUOaaiWkFKmWKZOUK-iXb1UgA184sTRpCVrKg.
issueAdvice=auto
services=mail,talk,writely,ig,toolbar,wise,reader,local,adwords,groups2,cf,cl,ah,chromiumsync,android,wave,lso,ahadmin,backup,googleme,oz,code,youtube,friendview,lh2,androidmarket,statement,googleplay,omaha,devconsole,chromewebstore,sj,bigquery,esmobile,webupdates,urlshortener,mapsengine,multilogin,androidconsole,grandcentral,mymaps,sitemaps,blogger,analytics,hist,nova
firstName=Konstantin
lastName=Razdolbaev

0 comments on commit 7517d9e

Please sign in to comment.