SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

Youtube OAuth authentification is KO with gdata-samples.java-1.35.1 (final accessToken is empty) #176

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.try OAuth authentification with Youtube and another API (like me, 
Picasa) (gdata-samples.java-1.31.1)
2.try OAuth authentification with Youtube and another API (like me, 
Picasa) (gdata-samples.java-1.35.1)
3. diff, first is OK, second is KO

What is the expected output? What do you see instead?
nothing, just an empty accessToken, -> process KO

What version of the product are you using? On what operating system?
gdata-samples.java-1.31.1 VS gdata-samples.java-1.35.1 on Windows XP and 
java 6, appengine 1.2.2, gwt 1.7

Please provide any additional information below.

I think you have a problem with the last gdata-samples

I used a Google API from gdata-samples.java-1.31.1. I try successfully 
OAuth authentification with Picasa and Youtube 
But now with gdata-samples.java-1.35.1 (wich resolve my problem with the 
YtPublicationState's State enum)
My callback token is in the request (sample 
oauth_token=CPXM87PoCxD61L27BA) but the accessToken for youtube is empty.
I try OAuth authentification for Picasa and it's still OK.

OAuthRsaSha1Signer signer = new OAuthRsaSha1Signer(RsaKeyUtil.getPrivateKey
());
GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);

oauthHelper.getOAuthParametersFromCallback(request.getQueryString(), 
oauthParameters); // request.getQueryString() during this test equals 
oauth_token=CPXM87PoCxD61L27BA

String accessToken = oauthHelper.getAccessToken(oauthParameters);

-> accessToken is sempty

Can you tell me if i'm right ?

Denis.

Original issue reported on code.google.com by denis.go...@gmail.com on 20 Aug 2009 at 8:38

GoogleCodeExporter commented 9 years ago
Hi there.  I've updated the following sample to use V1.35.1 of the Java client:

http://oauthexample.appspot.com/Welcome

You can also view the source here:

http://code.google.com/p/googleappengine/source/browse/#svn/trunk/java/demos/oau
th

Using that sample I was able to log into YouTube using OAuth RSA.  Can you 
compare 
and let me know if you have issues?  If you do have issues, it'd help to see 
how your 
code differs from the code in the sample.  Thanks!

Original comment by mon...@gmail.com on 25 Aug 2009 at 4:06

GoogleCodeExporter commented 9 years ago
I rollback to gdata-samples.java-1.31.1 and my code works.
What is the part of the sample ? 
../demos/oauth/ReceiveTokenControllerServlet.java ?

Here my code :

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthSignatureMethod("RSA-SHA1");
oauthParameters.setOAuthConsumerKey(myConsumerKey);

OAuthRsaSha1Signer signer = new OAuthRsaSha1Signer(RsaKeyUtil.getPrivateKey());
GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);

oauthHelper.getOAuthParametersFromCallback(request.getQueryString(), 
oauthParameters);

String accessToken = oauthHelper.getAccessToken(oauthParameters);

This code works with picasa and youtube for gdata-samples.java-1.31.1, but only 
picasa for gdata-samples.java-1.35.1. Maybe is the signature method (RSA-SHA1 
VS 
HMAC), i don't know, it's the only diff.

Original comment by denis.go...@gmail.com on 25 Aug 2009 at 5:27

GoogleCodeExporter commented 9 years ago
There weren't many changes introduced to the OAuth library between 1.31.1 and 
1.35.1.  
The biggest changes is that the RSA Signer added support for different private 
key 
formats (byte array and PrivateKey object, in addition to string).

Where do you set your callback url?  There were some changes between OAuth 1.0 
and 
1.0a that are affected by the callback url.  If you are setting it at the 
beginning 
of your code, try setting it right before calling createUserAuthorizationUrl().

One other thought, in your code snippet, what type does 
RsaKeyUtil.getPrivateKey() 
return (a byte array, a string, or a PrivateKey object)?  Can you verify that 
the key 
is a Base-64 encoded private key string conforming to the PKCS #8 standard?  
You can 
find instructions here:

http://code.google.com/apis/gdata/oauth.html#keytool

Original comment by mon...@gmail.com on 27 Aug 2009 at 7:36