Open sudheeshdh opened 4 years ago
I have the same problem. A few weeks ago everything worked fine, but now API can't login to my Google account with app password. When I use gplaymusic version 0.3.6, the app can login locally and everything works fine, but when I deploy it to AWS, it can't login anymore.
The exception:
19/11/16 16:59:13 ERROR speechlet.GoogleMusicSpeechlet: Error while auth token generating
Exception in thread "main" com.github.felixgail.gplaymusic.exceptions.InitializationException: AuthToken is not allowed to be null. Use TokenProvider.provideToken if you need to generate one.
svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
at com.github.felixgail.gplaymusic.api.GPlayMusic$Builder.build(GPlayMusic.java:335)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:104)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.main(GoogleMusicSpeechlet.java:302)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:90)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:38)
at com.github.felixgail.gplaymusic.util.TokenProvider.provideToken(TokenProvider.java:32)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.main(GoogleMusicSpeechlet.java:295)
This could mean, that they changed how the token generation works. i'll have a look
I am also tried another method for authentication, I generated a token using google auth2 login and provided received token from google to the library using the method
AuthToken authToken=TokenProvider.provideToken(tokenString);
('tokenString'
received from google signin from android devices)
and passing the authToken to the GplayMusic getting errors, the error getting seems like bad credentials.
GPlayMusic api = new GPlayMusic.Builder() .setAuthToken(authToken) .setDebug(false) .setHttpClientBuilder(builder) .build();
This is weird, since it works fine in my home network. Are both of you trying to use the library in an AWS environment?
Yes, it works in my home network too, but only version 0.3.6. Version 0.3.8 doesn't work. In AWS env no version works.
No, I haven't tried it from AWS and tried to implement this from my Android app.
Ok, i still had a working token in my cache. It looks like https://github.com/svarzee/gpsoauth-java is not working anymore. This means I will have to set the project status to broken until there is a patch to the library or another one has been found.
I don't believe it is related to the commit to the Python project that you referred to on the issue you posted for gpsoauth-java. The commit to the python project was over a year ago; this started failing about 2-3 weeks ago. I'm guessing the author for gpsoauth-java no longer maintains the project either which is a real bummer. Nothing I've played around with on either project has had any positive effect yet.
Does anyone have this working at the moment, I mean just for regular desktop logins (I'm not using AWS)?
I have tried using the latest version (0.7.0) of gpsoauth-java but I still get authentication failures.
I have the same experience with the gplaymusic: cannot generate token, neither from home network nor from aws.
PS. What's also strange, some of you mention version 0.3.8, and indeed it is present at https://mvnrepository.com/artifact/com.github.felixgail/gplaymusic/0.3.8 however I do not understand where from has it been generated. This github repo contains no branches/releases over 0.3.6 which is suspicious.
Just some more context...
I tried some of the applications based on the original python gmusicapi project and they still work with the same credentials that are failing here. That shows at least that the fundamental mechanism used of pretending to be a "real" google play client still works.
The problem originates from SSL implementation incompatibility. Gplaymusic passes OkHttpClient instance to Gpsoauth via constructor, for Gpsoauth to work OkHttpClient instance must be constructed with proper SSL implementation. The fix I introduced with gpsoauth-java:0.6.0 constructs a proper instance of OkHttpClient if you use the no parameters constructor of Gpsoauth.
(oh well... it could have been easier if gpsoauth-java used maven. I see gplaymusic refers to com.github.bjoernpetersen:gpsoauth that is no longer present on GitHub, but still is in mvncentral though; and there is another mavenized fork of gpsoauth by FelixGail itself, which anyway is not used by FelixGail's gplaymusic...)
@rinnnn just FYI I forked this and switched to using the up-to-date version of the "real" gpsoauth-java but unfortunately there must be more to it than simply that as I still couldn't get it working - but I didn't spend a large amount of time on it. I'm still trying to make it work.
@rinnnn https://mvnrepository.com/artifact/io.github.svarzee/gpsoauth-java
@caprica Have you used proper ssl implementation as explained in my previous comment?
@svarzee I've tried using the no-argument constructor for Gpsoauth as you mentioned, still getting a TokenRequestFailed.
@AshTheGoblin What jvm have you used?
@svarzee jre1.8.0_231
@AshTheGoblin I've verified it works on
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
What OS is it? Pls verify you are using the up to date dependency.
@svarzee thanks for replying
When I tried to troubleshoot this I did the following:
package com.github.felixgail.gplaymusic;
import svarzee.gps.gpsoauth.AuthToken;
import svarzee.gps.gpsoauth.Gpsoauth;
public class GPlayMusicAuthTest {
public static void main(String[] args) throws Exception {
System.out.println(System.getProperty("java.runtime.version"));
System.out.println(System.getProperty("java.home"));
System.out.println(System.getProperty("java.vm.vendor"));
// To confirm where the Gpsoauth class was loaded from
System.out.println(Gpsoauth.class.getProtectionDomain().getCodeSource().getLocation());
Gpsoauth auth = new Gpsoauth();
// These redacted credentials and device ID verified working using an equivalent Python library
String user = "my gmail address";
String password = "my application password";
String androidID = "my android device id";
// These pulled from the gplaymusic sources
AuthToken at = auth.login(user, password, androidID, "sj", "com.google.android.music", "AIzaSyARTC1h-_puqO0PHCHUoj1BTDjuAOxNVA8");
System.out.println(at);
}
}
pom.xml fragment:
<dependency>
<groupId>io.github.svarzee</groupId>
<artifactId>gpsoauth-java</artifactId>
<version>0.7.0</version>
</dependency>
program output:
1.8.0_241-b07
/disks/data/install/alternate-jdks/jdk1.8.0_241/jre
Oracle Corporation
file:/disks/data/maven-repo/io/github/svarzee/gpsoauth-java/0.7.0/gpsoauth-java-0.7.0.jar
Exception in thread "main" svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:166)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:152)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:100)
at com.github.felixgail.gplaymusic.GPlayMusicAuthTest.main(GPlayMusicAuthTest.java:21)
I also tried various other Java 8 JDK's, and JDK 11, with the same failure result.
Platform is Linux.
@caprica Seems like the SSL related problem, you are not getting 200 OK status code. Have you tried with hotspot 1.8.0_231 or openjdk 1.8.0_212?
@svarzee I don't have Oracle's 231 to try, I'll see if I can find a download for it.
In the meantime this is what I tried with your snapshot dependency:
1.8.0_241-b07
/disks/data/install/alternate-jdks/jdk1.8.0_241/jre
Oracle Corporation
file:/disks/data/maven-repo/io/github/svarzee/gpsoauth-java/0.8.0-SNAPSHOT/gpsoauth-java-0.8.0-20200126.144503-1.jar
Exception in thread "main" svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:166)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:152)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:100)
at com.github.felixgail.gplaymusic.GPlayMusicAuthTest.main(GPlayMusicAuthTest.java:21)
And OpenJDK:
1.8.0_212-b04
/disks/data/install/alternate-jdks/jdk8u212-b04/jre
AdoptOpenJDK
file:/disks/data/maven-repo/io/github/svarzee/gpsoauth-java/0.8.0-SNAPSHOT/gpsoauth-java-0.8.0-20200126.144503-1.jar
Exception in thread "main" svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:166)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:152)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:100)
at com.github.felixgail.gplaymusic.GPlayMusicAuthTest.main(GPlayMusicAuthTest.java:21)
Alternatively, is it possible something in this changed?
"sj", "com.google.android.music", "AIzaSyARTC1h-_puqO0PHCHUoj1BTDjuAOxNVA8"
And for context, I just downloaded and extracted those JDK's, I didn't install any other JCE files (I don't think that's a thing anymore is it?).
You can also try literally this:
auth.login("somerandomtestacc", "somerandompass", "9774d56d682e549c", "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com", "com.nianticlabs.pokemongo", "321187995bc7cdc2b5fc91b11a96e2baa8602c62");
I have this working now, but there's a but...
This project has this in its pom.xml:
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.12.0</version>
</dependency>
This was blocking the okhttp dependency that was specified by the gpsoath pom.xml.
You can either change this project's pom.xml to...
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
...or more simply just remove that dependency and rely on the proper gpsouth dependency instead.
This is the "but", I couldn't get it to work with gpsoauth 0.7.0, I had to use a 0.8.0-SNAPSHOT that @svarzee pointed me to, so this:
<dependency>
<groupId>io.github.svarzee</groupId>
<artifactId>gpsoauth-java</artifactId>
<version>0.8.0-SNAPSHOT</version>
</dependency>
Finally my original test program output is now this, showing a working authentication:
1.8.0_241-b07
/disks/data/install/alternate-jdks/jdk1.8.0_241/jre
Oracle Corporation
file:/disks/data/install/maven-repo/io/github/svarzee/gpsoauth-java/0.8.0-SNAPSHOT/gpsoauth-java-0.8.0-20200126.144503-1.jar
AuthToken{token='[REDACTED]', expiry=-1}
So I don't know what magic was done in 0.8.0-SNAPSHOT, but it seems necessary.
If I can find some time I'll maybe fork this and sort it out, I need #61 too and the original maintainer seems busy right now.
Thanks @svarzee for spending some time helping to resolve this.
@caprica I guess okhttp messes with SSL configuration. Google is very strict about SSL communication, even changes to order of preferred ciphers make it fail. gpsoauth-java v0.9.1 works with okhttp up to 3.6.0, it also handles a case when expiry header is missing.
This combination fixed the issue for me: com.squareup.okhttp3:okhttp:3.6.0 com.squareup.retrofit2:converter-gson:2.4.0 com.squareup.retrofit2:retrofit:2.4.0 java version "1.8.0_241"
@caprica Do you mind if I merged your changes back into this repository?
@FelixGail of course I don't mind, do whatever you want, your project was a great help to me so it's the least I can do.
Thanks.
The changes are available as a snapshot under 0.4.0R1-SNAPSHOT
Hi, @FelixGail, haven't you merged or pushed those changes yet? Version 0.4.0R1-SNAPSHOT
isn't available yet in maven repo and there are no new commits in your github repo neither.
It is available in the maven snapshot repository, but as this is not usable without the patch i might as well create a release
@olegshan Release 0.4.0 is now available
@FelixGail cool, thanks a lot. Will try it out today
@FelixGail still doesn't work for me. I tried both 0.4.0
and 0.4.0R1-SNAPSHOT
versions, my Java version is 1.8.0_241-b07
. I'm still getting the error while token generation:
svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
20/03/21 00:35:04 ERROR speechlet.GoogleMusicSpeechlet: Error while auth token generating
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:197)
svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:183)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:197)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:131)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:183)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:131)
at com.github.felixgail.gplaymusic.util.TokenProvider.provideToken(TokenProvider.java:32)
at com.github.felixgail.gplaymusic.util.TokenProvider.provideToken(TokenProvider.java:32)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.main(GoogleMusicSpeechlet.java:295)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.main(GoogleMusicSpeechlet.java:295)
Exception in thread "main" com.github.felixgail.gplaymusic.exceptions.InitializationException: AuthToken is not allowed to be null. Use TokenProvider.provideToken if you need to generate one.
at com.github.felixgail.gplaymusic.api.GPlayMusic$Builder.build(GPlayMusic.java:335)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.main(GoogleMusicSpeechlet.java:303)
I installed it on Lambda - the same result.
Interesting. I do get the same error now. The token generation has to have worked once though, since I have a different token than before. Even in the ci I cannot generate new tokens. Have you run the token generation multiple times, or did this fail instantly? If it worked once, Google may have changed the frequency in which you can generate master tokens. Either way this needs further investigation
It didn't work even once (
It is recommended to use Gpsoauth.compatibleOkHttpClient to create OkHttpClient instance with proper SSL settings.
Using jdk other than hotspot 1.8.0_231 or openjdk 1.8.0_212 may introduce SSL implementation problems.
Using` okhttp other than 3.4.1. 3.5.0, 3.6.0 may introduce SSL implementation problems.
Retrofit was using OkHttp 3.12 and didn't work with 3.6.0 so I downgraded retrofit to 2.4.0 and now everything seems to work. Can you check if 0.4.1R1-SNAPSHOT
works for you, too?
I can access 0.4.0R1-SNAPSHOT
, but 0.4.1R1-SNAPSHOT
can't be found when I add it to my pom.xml. Could you please check if it's published successfully?
0.4.1-SNAPSHOT sorry
It workes locally. But after deploying to AWS Lambda I get the same result ):
20/03/21 22:42:26 ERROR speechlet.GoogleMusicSpeechlet: Error while auth token generating
svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:197)
at svarzee.gps.gpsoauth.Gpsoauth.performMasterLoginForToken(Gpsoauth.java:183)
at svarzee.gps.gpsoauth.Gpsoauth.login(Gpsoauth.java:131)
at com.github.felixgail.gplaymusic.util.TokenProvider.provideToken(TokenProvider.java:31)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.prepareApi(GoogleMusicSpeechlet.java:266)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.onSessionStarted(GoogleMusicSpeechlet.java:43)
at com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:122)
at com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)
at com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:115)
at com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:89)
at lambdainternal.EventHandlerLoader$2.call(EventHandlerLoader.java:906)
at lambdainternal.AWSLambda.startRuntime(AWSLambda.java:341)
at lambdainternal.AWSLambda.<clinit>(AWSLambda.java:63)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at lambdainternal.LambdaRTEntry.main(LambdaRTEntry.java:119)
AuthToken is not allowed to be null. Use TokenProvider.provideToken if you need to generate one.: com.github.felixgail.gplaymusic.exceptions.InitializationException
com.github.felixgail.gplaymusic.exceptions.InitializationException: AuthToken is not allowed to be null. Use TokenProvider.provideToken if you need to generate one.
at com.github.felixgail.gplaymusic.api.GPlayMusic$Builder.build(GPlayMusic.java:335)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.prepareApi(GoogleMusicSpeechlet.java:273)
at com.olegshan.gplayalexa.speechlet.GoogleMusicSpeechlet.onSessionStarted(GoogleMusicSpeechlet.java:43)
at com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:122)
at com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)
at com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:115)
at com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:89)
But after testing in Alexa Developer Console, I found following in Alexa logs: "userAgent": "ask-java/1.8.1 Java/1.8.0_201"
. Will try to find out what the version of Java is used in Lambda and if it's possible to increase it.
I have been following this issue for a while, but was unavailable for some time now, I tried to add the dependency for 0.4.1-SNAPSHOT
but maven could not find it.
@olegshan and @FelixGail How do i go about this?
@chriseteka please add snapshot repositories support in your pom.xml
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>`
By the way, @FelixGail , it still doesn't work on AWS Lambda, since Java build version there is older and I can do nothing about it(
None of these are the correct way to get a token on an Android device. You should not be prompting the user for their username and password. Google would never allow an app that did this in the store for long.
You should be using the AccountManager to ask the user to choose their desired Google account on the device, and then use GoogleAuthUtils to request an OAuth token.
Intent intent = AccountManager.newChooseAccountIntent(null,
null,
new String[]{"com.google"},
false,
null,
null,
null,
null);
startActivityForResult(intent, ACCOUNT_CHOOSER_REQUEST_CODE);
token = GoogleAuthUtil.getToken(MainActivity.this, mAccount,
"oauth2:https://www.googleapis.com/auth/skyjam");
To do this properly you'll first need to make sure you have the google-services plugin (firebase) set up for your app and added your app signature to firebase, and pulled in google_services.json.
I finally came back around to using this in one of my projects, unfortunately it still fails to authenticate.
These are the dependencies that Maven pulls in with gplaymusic:
[INFO] +- com.github.felixgail:gplaymusic:jar:0.4.0:compile
[INFO] | +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] | +- com.squareup.retrofit2:retrofit:jar:2.5.0:compile
[INFO] | | \- com.squareup.okhttp3:okhttp:jar:3.12.0:compile
[INFO] | | \- com.squareup.okio:okio:jar:1.15.0:compile
[INFO] | +- com.squareup.retrofit2:converter-gson:jar:2.5.0:compile
[INFO] | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | +- io.github.svarzee:gpsoauth-java:jar:0.9.1:compile
[INFO] | | \- net.iharder:base64:jar:2.3.9:compile
[INFO] | \- io.gsonfire:gson-fire:jar:1.8.3:compile
This combination of gplaymusic + gpsoauth + okhttp + Java 1.8 just doesn't work for me.
If I downgrade okhttp to 3.6.0 as svarzee mentioned in a much earlier comment in this thread I can authenticate successfully:
<dependency>
<groupId>com.github.felixgail</groupId>
<artifactId>gplaymusic</artifactId>
<version>0.4.0</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.6.0</version>
</dependency>
BUT, it gives this error:
java.lang.NoSuchMethodError: okhttp3.Request$Builder.tag(Ljava/lang/Class;Ljava/lang/Object;)Lokhttp3/Request$Builder;
at retrofit2.RequestFactory.create(RequestFactory.java:112)
at retrofit2.OkHttpCall.createRawCall(OkHttpCall.java:190)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:173)
at com.github.felixgail.gplaymusic.api.GPlayMusic$Builder.build(GPlayMusic.java:371)
Clearly that's happening because of this downgrade.
Hi, I would like to integrate gplaymusic on my android app, for that purpose I integrated the codes in my activity class based on the instructions given. But I am not able to get a token from the TokenProvider.provideToken() method and getting exceptions from it. The exceptions seems to be "svarzee.gps.gpsoauth.Gpsoauth$TokenRequestFailed" and I tried multiple android devices OS version grater than 28 but getting same exception. Before integrating this I have logged in to google play music using my google credentials and able to play the songs in the library.
I have included the package in my build.gradle file as dependency.
implementation 'com.github.felixgail:gplaymusic:0.3.8'
Anything I am missed form this for getting the result ?