Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error=BadAuthentication #92

Open
achyut007 opened this issue Jun 5, 2017 · 5 comments
Open

Error=BadAuthentication #92

achyut007 opened this issue Jun 5, 2017 · 5 comments

Comments

@achyut007
Copy link

achyut007 commented Jun 5, 2017

Hi,
I am getting issue while trying to sign in into google account. I have automated script to download the apk files from Google Play store. The script was running fine till last week. But, recently getting following error related to akdeniz.googleplaycrawler library:

Exception in thread "main" com.akdeniz.googleplaycrawler.GooglePlayException: Error=BadAuthentication
at com.akdeniz.googleplaycrawler.GooglePlayAPI.executeHttpRequest(GooglePlayAPI.java:522)
at com.akdeniz.googleplaycrawler.GooglePlayAPI.executePost(GooglePlayAPI.java:482)
at com.akdeniz.googleplaycrawler.GooglePlayAPI.executePost(GooglePlayAPI.java:462)

and so on...
Currently, I am using googleplaycrawler-0.3.jar to download apk files from play store.
How can I resolve it? Can you please help me in this issue?

Thank you,
Achyut

@anton9088
Copy link

Use auth token for login instead email/password
egirault/googleplay-api#74

@SafwatHassan
Copy link

SafwatHassan commented Jul 17, 2017

When using the authentication token I get the following error in the login step

------------- Login Result -------------
LSID = [BAD_COOKIE]
SID = [BAD_COOKIE]

So I am asking if the code works fine with you. what is the key/value pairs that you used for the cookies.

@anton9088
Copy link

I used this repo for generate the auth token
https://github.com/yeriomin/token-dispenser

@SafwatHassan
Copy link

SafwatHassan commented Jul 18, 2017

@anton9088 I used the same repo to generate the token. So I have the following questions:

  1. the akdeniz's code makes 4 steps (checkin, login, checkin, then login):
- postCheckin
- loginAC2DM
- postCheckin
- login

So can you show a code snippet for the changes that you made to the code (i.e., which step that you bypassed).

Checkin:

   public AndroidCheckinResponse checkin() throws Exception {

	// this first checkin is for generating android-id
	AndroidCheckinResponse checkinResponse = postCheckin(Utils.generateAndroidCheckinRequest(deviceModel, SDK_Version).toByteArray());
	this.setAndroidID(BigInteger.valueOf(checkinResponse.getAndroidId()).toString(16));
	setSecurityToken((BigInteger.valueOf(checkinResponse.getSecurityToken()).toString(16)));

	String c2dmAuth = loginAC2DM();
	
	AndroidCheckinRequest.Builder checkInbuilder = AndroidCheckinRequest.newBuilder(Utils.generateAndroidCheckinRequest(deviceModel, SDK_Version));

	AndroidCheckinRequest build = checkInbuilder.setId(new BigInteger(this.getAndroidID(), 16).longValue())
		.setSecurityToken(new BigInteger(getSecurityToken(), 16).longValue()).addAccountCookie("[" + getEmail() + "]")
		.addAccountCookie(c2dmAuth).build();
	// this is the second checkin to match credentials with android-id
	return postCheckin(build.toByteArray());
    }

Then Login:

    /**
     * Authenticates on server with given email and password and sets
     * authentication token. This token can be used to login instead of using
     * email and password every time.
     */
    public void login() throws Exception {

	HttpEntity responseEntity = executePost(URL_LOGIN, new String[][] { { "Email", this.getEmail() }, { "Passwd", this.password },
		{ "service", "androidmarket" }, { "accountType", ACCOUNT_TYPE_HOSTED_OR_GOOGLE }, { "has_permission", "1" },
		{ "source", "android" }, { "androidId", this.getAndroidID() }, { "app", "com.android.vending" },
		{ "device_country", "us" }, { "lang", "en" }, { "sdk_version", SDK_Version }, }, null);

    	System.out.println("YYYYYYY Step 2: System could login with ID [" + this.getAndroidID() + "]");
	Map<String, String> response = Utils.parseResponse(new String(Utils.readAll(responseEntity.getContent())));
	if (response.containsKey("Auth")) {
	    setToken(response.get("Auth"));
	} else {
	    throw new GooglePlayException("Authentication failed!");
	}
    }

  1. The token-dispenser project has two token generation methods. Did you bypass the two checkin steps and used the checkin token and used the general token for the long step?

@anton9088
Copy link

I simply use GooglePlayAPI.login(String token) method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants