Fixed token not being used right after log in.

This commit is contained in:
Sergey Yeriomin
2016-12-13 22:40:08 +03:00
parent c34b86205a
commit d5353f63af
3 changed files with 6 additions and 14 deletions

View File

@@ -3,14 +3,14 @@ apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.github.yeriomin.yalpstore"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionName "0.1"
}
buildTypes {
release {

View File

@@ -89,14 +89,8 @@ class ThrottledHttpClient extends DefaultHttpClient {
HttpResponse response = this.execute(request);
this.lastRequestTime = System.currentTimeMillis();
int statusCode = response.getStatusLine().getStatusCode();
boolean isProtobuf = response.containsHeader("Content-Type")
&& response.getHeaders("Content-Type")[0].getValue().contains("protobuf");
byte[] content = readAll(response.getEntity().getContent());
if (!isProtobuf) {
throw new GooglePlayException(String.valueOf(statusCode) + " Thats not even protobuf: " + new String(content), statusCode);
}
if (statusCode >= 400) {
throw new GooglePlayException(String.valueOf(statusCode) + " Probably an auth error: " + new String(content), statusCode);
}

View File

@@ -112,20 +112,18 @@ public class PlayStoreApiWrapper {
gsfId = api.getGsfId();
prefsEditor.putString(AppListActivity.PREFERENCE_GSF_ID, gsfId);
prefsEditor.commit();
} else {
api.setGsfId(gsfId);
System.out.println("new gsfId " + gsfId);
}
System.out.println("new gsfId " + gsfId);
api.setGsfId(gsfId);
if (token.isEmpty()) {
token = api.getToken();
prefsEditor.putString(AppListActivity.PREFERENCE_EMAIL, email);
prefsEditor.putString(AppListActivity.PREFERENCE_PASSWORD, password);
prefsEditor.putString(AppListActivity.PREFERENCE_AUTH_TOKEN, token);
prefsEditor.commit();
} else {
api.setToken(token);
System.out.println("new token " + token);
}
System.out.println("new token " + token);
api.setToken(token);
} catch (GooglePlayException e) {
int code = e.getCode();
// auth/checkin requests answer with 401/403 when credentials are incorrect