Skip to content

Commit

Permalink
User profile method added
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed Mar 18, 2018
1 parent 28ec526 commit 4f81ca1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class GooglePlayAPI {
public static final int IMAGE_TYPE_YOUTUBE_VIDEO_LINK = 3;
public static final int IMAGE_TYPE_APP_ICON = 4;
public static final int IMAGE_TYPE_CATEGORY_ICON = 5;
public static final int IMAGE_TYPE_GOOGLE_PLUS_BACKGROUND = 15;

private static final String SCHEME = "https://";
private static final String HOST = "android.clients.google.com";
Expand All @@ -48,6 +49,8 @@ public class GooglePlayAPI {
private static final String CATEGORIES_URL = FDFE_URL + "categories";
private static final String TESTING_PROGRAM_URL = FDFE_URL + "apps/testingProgram";
private static final String LOG_URL = FDFE_URL + "log";
private static final String API_FDFE_URL = FDFE_URL + "api/";
private static final String USER_PROFILE_URL = API_FDFE_URL + "userProfile";

private static final String ACCOUNT_TYPE_HOSTED_OR_GOOGLE = "HOSTED_OR_GOOGLE";

Expand Down Expand Up @@ -675,6 +678,12 @@ public boolean reportAbuse(String packageName, ABUSE reason, String content) thr
return ResponseWrapper.parseFrom(client.post(ABUSE_URL, params, getDefaultHeaders())).getPayload().hasFlagContentResponse();
}

public UserProfileResponse userProfile() throws IOException {
return ResponseWrapperApi.parseFrom(
client.get(USER_PROFILE_URL, new HashMap<String, String>(), getDefaultHeaders())
).getPayload().getUserProfileResponse();
}

/**
* login methods use this
* Most likely not all of these are required, but the Market app sends them, so we will too
Expand Down
13 changes: 13 additions & 0 deletions src/main/proto/GooglePlay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,19 @@ message ResponseWrapper {
optional ServerCookies serverCookies = 7;
optional bytes serverLogsCookie = 9;
}
message ResponseWrapperApi {
optional PayloadApi payload = 1;
}
message PayloadApi {
optional UserProfileResponse userProfileResponse = 5;
}
message UserProfileResponse {
optional UserProfile userProfile = 1;
}
message UserProfile {
optional string userId = 2;
repeated Image image = 10;
}
message ServerCommands {
optional bool clearCache = 1;
optional string displayErrorMessage = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,16 @@ public void reportAbuse() throws Exception {
Assert.assertTrue(api.reportAbuse("com.github.yeriomin.smsscheduler", GooglePlayAPI.ABUSE.IMPERSONATION, ""));
}

@Test
public void userProfile() throws Exception {
UserProfileResponse response = api.userProfile();
Assert.assertTrue(response.hasUserProfile());
Assert.assertEquals("115275627922389268197", response.getUserProfile().getUserId());
Assert.assertEquals(2, response.getUserProfile().getImageCount());
Assert.assertEquals(4, response.getUserProfile().getImage(0).getImageType());
Assert.assertEquals("https://lh5.googleusercontent.com/-NxRLoKjJ7LM/AAAAAAAAAAI/AAAAAAAAAAA/AGi4gfwqBhB2A69d0pMdvrYAhASD_01wVA/photo.jpg", response.getUserProfile().getImage(0).getImageUrl());
}

private GooglePlayAPI initApi() {
Properties properties = new Properties();
try {
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/request.fdfe.api.userProfile.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

�*�
�
person-115275627922389268197115275627922389268197 *User YalpstoreR|*shttps://lh5.googleusercontent.com/-NxRLoKjJ7LM/AAAAAAAAAAI/AAAAAAAAAAA/AGi4gfwqBhB2A69d0pMdvrYAhASD_01wVA/photo.jpgH�R�*zhttps://lh3.googleusercontent.com/c5dqxl-2uHZ82ah9p7yxrVF1ZssrJNSV_15Nu0TUZwzCWqmtoLxCUJgEzLGtxsrJ6-v6R6rKU_-FYm881TTiMCJ_Hjb"

0 comments on commit 4f81ca1

Please sign in to comment.