AndlyticsProject / andlytics

Google Play - Android Market statistics app
Other
535 stars 181 forks source link

What are the steps to run my own copy of this app? #740

Open casolorz opened 7 years ago

casolorz commented 7 years ago

I want to familiarize myself with this app to see if I can add some features I want.

I cloned the repo and when I run it I get:

Unrecoverable authentication exception: UNREGISTERED_ON_API_CONSOLE

So I then created my own oauth2 client credentials using my own keystore and sha1 and then I get this error:

Unrecoverable authentication exception: INVALID_SCOPE

Sow what else do I need to change?

Thanks.

AndyScherzinger commented 7 years ago

@nelenkov @willlunniss do you know/remember what needs to be done?

nelenkov commented 7 years ago

@casolorz Do you have Play Store Developer account? You need to login to the app with the same Google account you used to register as a developer in order to see any data.

Not sure where you added oauth2 credentials, but those are not really needed.

casolorz commented 7 years ago

@nelenkov yeah I have been using Andlytics for a while now but wanted to run my own copy so I can start modifying it.

I added the oauth2 client under this page https://console.developers.google.com/apis/credentials

I saw something about a Dropbox folder containing keys for signing but I couldn't find any Dropbox folder.

nelenkov commented 7 years ago

You might want to provide a stacktrace, so we have a chance to figure out what the cause is.

casolorz commented 7 years ago

This is the stacktrace without modifying the signing key.

03-13 21:16:46.699 31581-31811/com.github.andlyticsproject E/OauthAccountManagerAuthenticator: Unrecoverable authentication exception: UNREGISTERED_ON_API_CONSOLE
                                                                                               com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE
                                                                                                   at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                   at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                   at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:123)
                                                                                                   at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                                                   at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                                                   at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateWithCachedCredentialas(DevConsoleV2.java:324)
                                                                                                   at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:97)
                                                                                                   at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                                                   at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                                                   at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                                                   at java.lang.Thread.run(Thread.java:761)
03-13 21:16:46.959 31581-31811/com.github.andlyticsproject E/OauthAccountManagerAuthenticator: Unrecoverable authentication exception: UNREGISTERED_ON_API_CONSOLE
                                                                                               com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE
                                                                                                   at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                   at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                   at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:123)
                                                                                                   at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                                                   at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                                                   at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:328)
                                                                                                   at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:103)
                                                                                                   at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                                                   at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                                                   at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                                                   at java.lang.Thread.run(Thread.java:761)
03-13 21:16:46.960 31581-31811/com.github.andlyticsproject E/Main: Error while requesting developer console : com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:139)
                                                                   com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                   com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                   com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:328)
                                                                   com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:103)
                                                                   com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                   com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                   android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                   java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                   java.lang.Thread.run(Thread.java:761)
03-13 21:16:46.963 31581-31811/com.github.andlyticsproject E/Main: Error while requesting developer console : Authentication error: UNREGISTERED_ON_API_CONSOLE
                                                                   com.github.andlyticsproject.console.AuthenticationException: Authentication error: UNREGISTERED_ON_API_CONSOLE
                                                                       at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:139)
                                                                       at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                       at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                       at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:328)
                                                                       at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:103)
                                                                       at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                       at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                       at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                       at java.lang.Thread.run(Thread.java:761)

When I switch the signing key to my own, the one that I registered the sha1 for, I get this:

03-13 21:22:24.798 7072-7137/com.github.andlyticsproject E/OauthAccountManagerAuthenticator: Unrecoverable authentication exception: INVALID_SCOPE
                                                                                             com.google.android.gms.auth.GoogleAuthException: INVALID_SCOPE
                                                                                                 at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                 at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                 at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:123)
                                                                                                 at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                                                 at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                                                 at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateWithCachedCredentialas(DevConsoleV2.java:324)
                                                                                                 at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:97)
                                                                                                 at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                                                 at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                                                 at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                                                 at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                                 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                                                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                                                 at java.lang.Thread.run(Thread.java:761)
03-13 21:22:24.913 7072-7137/com.github.andlyticsproject E/OauthAccountManagerAuthenticator: Unrecoverable authentication exception: INVALID_SCOPE
                                                                                             com.google.android.gms.auth.GoogleAuthException: INVALID_SCOPE
                                                                                                 at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                 at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
                                                                                                 at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:123)
                                                                                                 at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                                                 at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                                                 at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:328)
                                                                                                 at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:103)
                                                                                                 at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                                                 at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                                                 at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                                                 at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                                 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                                                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                                                 at java.lang.Thread.run(Thread.java:761)
03-13 21:22:24.914 7072-7137/com.github.andlyticsproject E/Main: Error while requesting developer console : com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:139)
                                                                 com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                 com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                 com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:328)
                                                                 com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:103)
                                                                 com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                 com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                 android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                 java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                 java.lang.Thread.run(Thread.java:761)
03-13 21:22:24.914 7072-7137/com.github.andlyticsproject E/Main: Error while requesting developer console : Authentication error: INVALID_SCOPE
                                                                 com.github.andlyticsproject.console.AuthenticationException: Authentication error: INVALID_SCOPE
                                                                     at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticateInternal(OauthAccountManagerAuthenticator.java:139)
                                                                     at com.github.andlyticsproject.console.v2.OauthAccountManagerAuthenticator.authenticate(OauthAccountManagerAuthenticator.java:71)
                                                                     at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:349)
                                                                     at com.github.andlyticsproject.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:328)
                                                                     at com.github.andlyticsproject.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:103)
                                                                     at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:558)
                                                                     at com.github.andlyticsproject.Main$LoadRemoteEntries.doInBackground(Main.java:525)
                                                                     at android.os.AsyncTask$2.call(AsyncTask.java:305)
                                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                     at java.lang.Thread.run(Thread.java:761)
nelenkov commented 7 years ago

Not sure why you are getting this, but try using the same account to sign into Chrome on your Android device first. Andlytics is basically emulating the Chrome protocol.

You could also try replacing OauthAccountManagerAuthenticator with PasswordAuthenticator (which takes your Google account password as input) to see if you can authenticate.

The API console registration should only be needed for accessing the AdSense API, but things on Google's side could have changed.

magnusgronbek commented 7 years ago

I also get invalid_scope when trying to get token

nelenkov commented 7 years ago

As for building your own version, adding the package name and your signing certificate hash to Google APIs console should be enough. See attached image: api-console

magnusgronbek commented 7 years ago

I did that but it doesn't help. If i remove the certificate I get unregistered_on_api_console. And if I add the certificate I get invalid_token.

nelenkov commented 7 years ago

Hm, is it possible that you can only add a limited number of certs?

magnusgronbek commented 7 years ago

I also tried to change the package name in build.gradle (applicationId) and created a new certificate in google api console but that didn't work either. Still getting invalid_scope.

casolorz commented 7 years ago

Just like @magnusgronbek I tried creating my own certificate hash, tried changing package name, etc. Nothing seemed to help. I can probably play with this again in a couple of weeks.

nelenkov commented 7 years ago

Not sure why this happens. Could be related to Google Paly services version, although a bit unlikely if Andlytics release build runs on the same device.

You could try modifying the code to use the PasswordAuthenticator to see if it makes a difference. Should work with a Google app-specific password, not just our raw password.

https://github.com/AndlyticsProject/andlytics/blob/b70ff47a1d01ce01d4d5eb27ea7c42e29be83f9b/src/com/github/andlyticsproject/console/v2/PasswordAuthenticator.java

magnusgronbek commented 7 years ago

Has anyone managed to get there own copy of the project working?

casolorz commented 7 years ago

Nope.

hasanjamshaid commented 7 years ago

I am facing the same issue. INVALID_SCOPE with OauthAccountManagerAuthenticator.

Tried all possible steps including

  1. adding "OAuth 2.0 client IDs" and setting package name and Signing-certificate fingerprint.
  2. Also enable api access on developer account. I tried linking it on the developer account https://play.google.com/apps/publish/?dev_acc=_________#ApiAccessPlace

do we need to enable libraries on https://console.developers.google.com/apis/library page for this project?

I tried PasswordAuthenticator as well getting below error; after i enter password 06-24 02:23:20.547 3989-4153/com.github.andlyticsprojectcp E/Main: Error while requesting developer console : Couldn't find StartupData JSON object. com.github.andlyticsprojectcp.console.AuthenticationException: Couldn't find StartupData JSON object. at com.github.andlyticsprojectcp.console.v2.BaseAuthenticator.createSessionCredentials(BaseAuthenticator.java:171) at com.github.andlyticsprojectcp.console.v2.PasswordAuthenticator.authenticate(PasswordAuthenticator.java:97) at com.github.andlyticsprojectcp.console.v2.PasswordAuthenticator.authenticate(PasswordAuthenticator.java:53) at com.github.andlyticsprojectcp.console.v2.DevConsoleV2.authenticate(DevConsoleV2.java:348) at com.github.andlyticsprojectcp.console.v2.DevConsoleV2.authenticateFromScratch(DevConsoleV2.java:327) at com.github.andlyticsprojectcp.console.v2.DevConsoleV2.getAppInfo(DevConsoleV2.java:102) at com.github.andlyticsprojectcp.Main$LoadRemoteEntries.doInBackground(Main.java:558) at com.github.andlyticsprojectcp.Main$LoadRemoteEntries.doInBackground(Main.java:525) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762)

AndroidSources commented 6 years ago

Did the clone worked for anyone ?