Giter Club home page Giter Club logo

Comments (39)

proxyblue avatar proxyblue commented on August 16, 2024 3

So, after a bit of experimenting, I couldn't get it to work via the username / password authentication - but I was able to get it working again with token authentication.

I used this repo to help generate a token - not sure yet how long the token lasts for, but I suspect I'll need to spin something up to generate tokens and store them in case it fails again.

But at least it all works again :)

https://github.com/yeriomin/token-dispenser

from googleplay-api.

jr3074 avatar jr3074 commented on August 16, 2024 1

@louiscremen
ok, thanks, it works now :D

from googleplay-api.

rainorz avatar rainorz commented on August 16, 2024 1

@louiscremen Great! It works! Many thanks!

from googleplay-api.

GoyfAscetic avatar GoyfAscetic commented on August 16, 2024

I'm getting this same error but only when logging in with a phone

from googleplay-api.

kobibo avatar kobibo commented on August 16, 2024

I also have the same problem. I have just noticed that for some reason if I try to run the query over and over again it actually works (partially). Still have the problem in advance but the API actually shows signs of life.

from googleplay-api.

cryptax avatar cryptax commented on August 16, 2024

Same problem. It used to work, has the google API changed?

from googleplay-api.

OmkarSharan avatar OmkarSharan commented on August 16, 2024

same problem here :(

from googleplay-api.

proxyblue avatar proxyblue commented on August 16, 2024

Same problem

from googleplay-api.

jr3074 avatar jr3074 commented on August 16, 2024

@louiscremen how to setting the token in googleplay-api? i have token-dispenser server

from googleplay-api.

proxyblue avatar proxyblue commented on August 16, 2024

Change AUTH_TOKEN to your token in config.py

  | ANDROID_ID      = None # "xxxxxxxxxxxxxxxx"
  | GOOGLE_LOGIN    = None # "[email protected]"
  | GOOGLE_PASSWORD = None
  | AUTH_TOKEN      = None # "yyyyyyyyy"

Or if you're using the googleplay object, just pass in the authSubToken as a parameter. Depends on how you're using the project.

def login(self, email=None, password=None, authSubToken=None):

from googleplay-api.

feng13314 avatar feng13314 commented on August 16, 2024

@louiscremen how can us get the auth_token?

from googleplay-api.

proxyblue avatar proxyblue commented on August 16, 2024

Hi @feng13314 ,

I recommend following the instructions in the below project. You can set it up to generate static tokens in a text file, or a running server to generate tokens on demand. Depends on your needs.

https://github.com/yeriomin/token-dispenser

from googleplay-api.

feng13314 avatar feng13314 commented on August 16, 2024

Hi @louiscremen ,

 How long the auth_token's validity? Do you test it?

from googleplay-api.

proxyblue avatar proxyblue commented on August 16, 2024

I fixed this two days ago and the token is still valid.

I guess.. I won't know properly until it stops working. I'll post when that happens, I run this daily and get daily emails based on the results of this script.

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

@louiscremen : I am trying the same method as you have guided earlier, but when I am configuring the MVN, It is generating an error relating some build error. Can you please help in configuring the token-dispenser project.

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

@louiscremen :
avinash.af.kumar@AMAC02Q4JZ5G8WP ~/Desktop/apache-maven-3.2.2/bin $ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.072 s
[INFO] Finished at: 2017-07-14T17:56:21+05:30
[INFO] Final Memory: 6M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/user1/Desktop/apache-maven-3.2.2/bin). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectExcept

from googleplay-api.

proxyblue avatar proxyblue commented on August 16, 2024

If you're having issues with building the token project, I recommend filing an issue in the token project.

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

Thanks a lot for your help you are very supportive. I had the same issue few days ago and I am using Akdeniz/google-play-crawler.
I applied your solution and I could generate token ID.
Now I am trying to modify the Akdeniz's code to send the token ID. So I read the code for the googleplay.py (the login method).
The login method as you said mandates either using user email and password or a token.
But the strange thing that the googleplay.py login just sets the token in the googleplay object and does not send it as a parameter to Google. So I am wondering what should be the parameter name and value for sending the token.

I find this article useful https://sbktech.blogspot.ca/2014/01/inside-android-play-services-magic.html

So I simulated the code by just calling the login method with 1) the email and password as null and 2) added Token parameter and 3) set the Android ID with my device Android ID but then I got error Forbidden which is mapped to BadAuthentication error!

So can you please tell me the list of submitted parameters may be I missed a parameter.

One last thing, I read the python files (download ...) they just call the login method then get the data.
So we do not need to checkin we just call the authentication step with the token an Android ID correct?

Your help is really appreciated !

[Updated]:
Now I could login I changed in the method that returns the Token instead of reading the auth parameter it reads the Token parameter.

Now when I run the method to get the details I gt the following error:

HTTP/1.1 400 Bad Request
Error retrieving information from server. [RH-02]

Did anyone see this error before?

People on the internet recommend that error [RH-01] could be fixed by restarting the device but our error code is [RH-02] also we do not have device to restart!

from googleplay-api.

jr3074 avatar jr3074 commented on August 16, 2024

well, this problem has been solved by using token, for the other problem please open new issue

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

Thanks everyone for the effort.
I used the recommended approach to get the Token.
Then, I checked out the python code and run the download function and I get the Bad authentication error.

The solution does not work at all!

In addition, the googleplay.py script has a bug in line 109 (i.e., params ... ) .
This line should be on the same level as the if and else statements. I will open this coding bug in another issue.

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

Thanks, everyone. The solution is working for me now. I am able to use token to search and download the apps.

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

@avinashkmr632 So how it works for you. Can you please help. I have the following questions:

  1. The login method in the googleplay.py does not send the Token parameter in the HTTP request so did you modified the code and added the Token parameter to the submitted parameters?
  2. The googleplay.py does not send any request at all if the Token value is set, so did you fixed this bug in the googleplay.py init method?
  3. Can you provide sample of the working code and working configuration (i.e, token)

@louiscremen:
Can you please tell me what is the problem in my code.

Here is the detail error

$ python download.py com.bfs.ninjump
/lib/python2.7/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
Response for login is <Response [403]>
Traceback (most recent call last):
  File "download.py", line 29, in <module>
    api.login(GOOGLE_LOGIN, GOOGLE_PASSWORD, AUTH_TOKEN)
  File "/PythonCrawler/googleplay-api/googleplay.py", line 140, in login
    raise LoginError("server says: " + params["error"])
googleplay.LoginError: u'server says: BadAuthentication'

I logged all the sent parameters and I removed the android ID from the logging

Here is also the modified code:


    def login(self, email=None, password=None, authSubToken=None):
        """Login to your Google Account. You must provide either:
        - an email and password
        - a valid Google authSubToken"""
        print "Login with parameters authSubToken [%s] " % authSubToken
        if (authSubToken is not None):
            self.setAuthSubToken(authSubToken)
        else:
            if (email is None or password is None):
                raise Exception("You should provide at least authSubToken or (email and password)")
        params = {
                "Tocken": self.authSubToken,
                "service": self.SERVICE,
                  "accountType": self.ACCOUNT_TYPE_HOSTED_OR_GOOGLE,
                  "has_permission": "1",
               "source": "android",
               "androidId": self.androidId,
                "app": "com.android.vending",
                    #"client_sig": self.client_sig,
                "device_country": "fr",
                "operatorCountry": "fr",
                "lang": "fr",
                "sdk_version": "16"}
        headers = {
                "Accept-Encoding": "",
            }
        print "Login with parameters params [%s] " % params

        response = requests.post(self.URL_LOGIN, data=params, headers=headers, verify=False)
        print "Response for login is %s" % response
        data = response.text.split()
        params = {}
        for d in data:
            if not "=" in d: 
                continue
            k, v = d.split("=")
            params[k.strip().lower()] = v.strip()
            if "auth" in params:
               self.setAuthSubToken(params["auth"])
            elif "error" in params:
               raise LoginError("server says: " + params["error"])
            else:
               raise LoginError("Auth token not found.")

When I revert back to the old code I get the following error:

(ENV) Safwats-MacBook-Pro: ~/Desktop/Learn/Scrapy/ENV/PythonCrawler/googleplay-api2 $ python download.py com.facebook.katana
/lib/python2.7/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
Traceback (most recent call last):
  File "download.py", line 34, in <module>
    ot = doc.offer[0].offerType
  File "/lib/python2.7/site-packages/google/protobuf/internal/containers.py", line 204, in __getitem__
    return self._values[key]
IndexError: list index out of range

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

Actually, I did not change much in the code. I just added the Auth Token in config.py file and everything worked smoothly. Just try generating the Auth Token from https://github.com/yeriomin/token-dispenser

Just download the fresh code. Edit all the field in config.py and also add the Auth Token generated. And try running the code. I hope you will get the result.

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

@SafwatHassan :IndexError might be coming because of this issue.
#73.
Check this once.

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

screen shot 2017-07-19 at 1 08 20 pm

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

@avinashkmr632 So I did as you recommended:

  1. Checked out the latest googleplay-api code.
  2. Used the project token-dispenser to generate token

I tried both running the Spark server or using a simple java code that calls the token generation:


package com.github.yeriomin.tokendispenser;

import java.io.IOException;

public class TokenGenerator
{
	public static String generateAc2dmToken(String email, String password) throws IOException 
	{
		TokenAc2dmResource ac2dmResource = new TokenAc2dmResource();
		String tokenValue = ac2dmResource.getToken(email, password);
		return tokenValue;
	}

	public static String generateGeneralToken(String email, String password) throws IOException 
	{
		TokenResource tokenResource = new TokenResource();
		String tokenValue = tokenResource.getToken(email, password);
		return tokenValue;
	}

	
	public static void main(String[] args) throws Exception
	{
		String generalToken = generateGeneralToken("[email protected]","Crawler_PW_20");
		System.out.println("The general token is [" + generalToken +"]");
		
		String ac2dmToken = generateAc2dmToken("[email protected]","Crawler_PW_20");
		System.out.println("The AC2DM token is [" + ac2dmToken +"]");
	}
}

  1. Added the configuration for my device, email, password, and Token.
    I used the General token (not the AC2DM one).

  2. Changed the googleplay.py file as recommended in the issue #73

/PythonCrawler $ diff googleplay-api3/googleplay.py googleplay-api2/googleplay.py
130c130,132
<                 k, v = d.split("=")
---
>                 matchObj  = re.match("([^=]+)=(.*)",d)
>                 k=matchObj.group(1)
>                 v=matchObj.group(2)

  1. Run the code and I still get the error:

/PythonCrawler/googleplay-api2 $ python download.py com.facebook.katana
/lib/python2.7/site-packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
Traceback (most recent call last):
  File "download.py", line 34, in <module>
    ot = doc.offer[0].offerType
  File "/lib/python2.7/site-packages/google/protobuf/internal/containers.py", line 204, in __getitem__
    return self._values[key]
IndexError: list index out of range

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

@avinashkmr632

  1. I used both general token and the ac2dm tokens and does not work.
  2. Can you print one value for valid token so i test with it.
  3. Is the InsecureRequestWarning is an issue (see my logs).
  4. I do not expect that the googleplay.py sends any request at all when the Token value is set.
    So could you please make diff between the googleplay.py on git hub and your local file.
    I just need to see the changed lines.

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

The issue is solved, I was using my actual device ID and when I used the testing Device ID it works.
Thanks @avinashkmr632 for your help!

from googleplay-api.

avikmrr avatar avikmrr commented on August 16, 2024

@SafwatHassan : Great Work.

from googleplay-api.

Maria06 avatar Maria06 commented on August 16, 2024

@avinashkmr632

Can you please tell me how you generate the Auth token ? I followed https://github.com/yeriomin/token-dispenser for generating Auth token but iam getting the error when i did the step 4 mvn install

sarath@agaze-dev-001:~/Desktop/GooglePlay/token-dispenser-master$ mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building token-dispenser 0.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ token-dispenser ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ token-dispenser ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /home/sarath/Desktop/GooglePlay/token-dispenser-master/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.827 s
[INFO] Finished at: 2017-07-31T21:23:57+05:30
[INFO] Final Memory: 10M/211M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project token-dispenser: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

from googleplay-api.

4knahs avatar 4knahs commented on August 16, 2024

For people checking this thread in the future, the following (while not perfect, e.g., does not kill the process etc) exemplifies the use of the token dispenser:

#!/usr/bin/python

## Before running do on the root folder:
## git clone https://github.com/yeriomin/token-dispenser.git
## cd token-dispencer; mvn install
## cd src/resources and edit config.properties to have:
###### spark-host=0.0.0.0
###### spark-port=8080
###### storage=plaintext
###### storage-plaintext-path=passwords.txt
###### enable-email-retrieval=false

# Do not remove
GOOGLE_LOGIN = GOOGLE_PASSWORD = AUTH_TOKEN = None

import sys
from pprint import pprint

#Added to call the token-dispenser
import shlex, subprocess, requests, time

from config import *
from googleplay import GooglePlayAPI
from helpers import sizeof_fmt

if (len(sys.argv) < 2):
    print "Usage: %s packagename [filename]"
    print "Download an app."
    print "If filename is not present, will write to packagename.apk."
    sys.exit(0)

f = open('token-dispenser/passwords.txt', 'w') #truncates the file
f.write(GOOGLE_LOGIN + " " + GOOGLE_PASSWORD)
f.close

#dont forget to run mvn install on token-dispenser folder
cmd = 'java -jar token-dispenser/target/token-dispenser.jar'
dispenser = subprocess.Popen(shlex.split(cmd)) # this will launch detached

packagename = sys.argv[1]

if (len(sys.argv) == 3):
    filename = sys.argv[2]
else:
    filename = packagename + ".apk"

cmd = "http://localhost:" + TOKEN_PORT + "/token/email/" + GOOGLE_LOGIN
r = None

counter = 5
while r == None or (r.status_code != 200 and counter >= 0):
    try:
        r = requests.get(cmd)
    except Exception as err:
        pass

    time.sleep(1)
    counter-=1

# Connect
api = GooglePlayAPI(ANDROID_ID)
api.login(None, None, r.text)

# Get the version code and the offer type from the app details
m = api.details(packagename)

if len(m.docV2.offer) == 0:
    print "[Could not get API details]"
    sys.exit(3)

doc = m.docV2
vc = doc.details.appDetails.versionCode
ot = doc.offer[0].offerType

# Download
print "Downloading %s..." % sizeof_fmt(doc.details.appDetails.installationSize),
data = api.download(packagename, vc, ot)
open(filename, "wb").write(data)
print "Done"

from googleplay-api.

Maria06 avatar Maria06 commented on August 16, 2024

@SafwatHassan

Can you please help ? I also facing the same issue with the IndexError .

  1. I got the token from the token-dispenser by writing a simple java code and I try with both general token and the ac2dm tokens in config.py file in googleplay-api
    2.I used the device Id generate by
final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
 String deviceid = tm.getDeviceId();

3.My email id and password in config.py

4.When i run the command python download.py com.agaze.ugo_trucks it is getting IndexError: list index out of range

/home/sarath/.local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:838: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html
  InsecureRequestWarning)
Traceback (most recent call last):
  File "download.py", line 34, in <module>
    ot = doc.offer[0].offerType
IndexError: list index out of range

from googleplay-api.

SafwatHassan avatar SafwatHassan commented on August 16, 2024

@Maria06 Actually I did not run this crawler, my crawler uses the Akdeniz crawler https://github.com/Akdeniz/google-play-crawler. What I did is the following:

  1. I used the token generator project and generated token. As you said, you can simply just call the java class that generates the token and no need to install Spark server.
  2. I use https://github.com/Akdeniz/google-play-crawler to generate Android ID (the method postCheckin in the class GooglePlayAPI.java)
  3. I use the generated token + Android ID + email and password to call the method details in the class GooglePlayAPI.java)

Here is my main testing method:

 public static void main(String[] args) throws Exception
  	{
      	String 	loaclAddressString = Inet6Address.getLocalHost().getHostAddress();

       // I just refactored the code to has the email, password, device model and SDK version as parameters
      	GooglePlayAPI service = new GooglePlayAPI("email", "password", loaclAddressString, "GT-I9300", "13");
      	
      	service.generateAndoirdID();
      	service.generateToken();
      	System.out.println("Generated Token is [" +  service.generalToken + "]");

      	System.out.println("Generated Android ID is [" +  service.androidID + "]");
      	
      	DetailsResponse res = service.details("com.bfs.ninjump");
      	
      	System.out.println(res);
  	}

The main showstopper for me was the Android ID as I was using my Device Android ID and it seems that it was blocked so I recommend that you try different Android IDs for different devices.

You can get the Android ID for a device using app called Device ID or pass your IMEI or your Android Device ID both will work.

For me I did not try to run the code for this project as it gave me the Index error. Instead my code uses the Akdeniz crawler but I used the token generation code to generate token then use it with Akdeniz crawler code.

from googleplay-api.

zhang-li avatar zhang-li commented on August 16, 2024

@4knahs
Thanks for sharing your code. I managed to execute your code.
However, the statement "r = request.get(cmd)" just returns r being <Response [404]>.
May I know what are the possible reasons for this?

the cmd I used is
cmd = "http://localhost:" + "8080" + "/token/email/" + GOOGLE_LOGIN

from googleplay-api.

gaoying0805 avatar gaoying0805 commented on August 16, 2024

@proxyblue Hi, Can you please help ? I also facing the same issue that login error badauthentication .
sorry, my english is poor.

from googleplay-api.

gaoying0805 avatar gaoying0805 commented on August 16, 2024

@proxyblue yesterday,i tried run the googleplay-api code,but i facing the login error badauthentication.
and my company have not the spark so i could not follow https://github.com/yeriomin/token-dispenser
.

from googleplay-api.

gaoying0805 avatar gaoying0805 commented on August 16, 2024

@avinashkmr632 hi,Can you please help ? I also facing the same issue that login error badauthentication .
sorry, my english is poor.

from googleplay-api.

Sinkler avatar Sinkler commented on August 16, 2024

Don't use special characters in your password If you have BadAuthentication error: mgp25/SC-API#30 (comment)

from googleplay-api.

GoyfAscetic avatar GoyfAscetic commented on August 16, 2024

So I used Token dispenser to get rid of the bad Auth error once before but now it's back. I haven't got it working yet.

  • I tried removing special characters from the password.
  • I've tried creating and using a new token.
  • I tried adding a credit card to my account as that is required now.

None of that worked. Has anyone ran into this issue after using the token dispenser?

from googleplay-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.