SilverHoodCorp / gdata-java-client

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

Error getting HTTP response #292

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
gdata-client-1.0-1.41.3
gdata-core-1.0-1.41.3
google-collections-1.0-rc1
gdata-contacts-3.0-1.41.3
Java 1.6

If I run the code below (using either RSA and HMAC) on my development Windows 
XP laptop (java 1.6.0.20) it works.    However, if I run the exact same code on 
my production Linux server (1.6.0.06), it fails with the error:  "Error getting 
HTTP response".  This exception is being raised on the following line:

com.google.gdata.client.authn.oauth.OAuthException: Error getting HTTP response
        at com.google.gdata.client.authn.oauth.OAuthHttpClient.getResponse(OAuth
HttpClient.java:76)

Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL:
 https://www.google.com/accounts/OAuthGetRequestToken?oauth_callback=http%3A%2F%
2Fwww.ezlista.com%2Ftools%2FgoogleOauthCallback.do&scope=http%3A%2F%2Fwww.google
.com%2Fm8%2Ffeeds%2F&oauth_nonce=15504767313444759&oauth_signature_method=RSA-SH
A1&oauth_consumer_key=www.ezlista.com&oauth_timestamp=1279238836&oauth_signature
=2TzskEtA9%2FYy%2BfYLYMJNqEFsCh8vkjcTWlMXp0qMwNUfEJSAn417jz2IrZ8xgY0F%2BgBgB8Fwn
rLnlG%2Fbzhfijq9IMHhEo%2FOH7eI62y7qILDOHnE5CoUDkXK0k%2Bp7HJ3HKQ0GgOXz9S23ncEsTRV
asE%2FpnJHG1qqVc%2BbAfgyQ83Y%3D

Any clues?  

...
GoogleOAuthHelper oauthHelper = null;
String signerType = ApplicationProperty.getInstance().getGoogleOAuthSigner();
if("RSA-SHA1".equalsIgnoreCase(signerType))
{
    PrivateKey privKey =
        getRSAPrivateKey(ApplicationProperty.getInstance().getGoogleOAuthRSAKeyFile());
    OAuthRsaSha1Signer signer = null;
    try
    {
        signer = new OAuthRsaSha1Signer(privKey);
    }
    catch(OAuthException ex)
    {
        String msg = "Error creating a OAuth RSA signer: " + ex.getMessage();
        logger.error(msg);
        throw new IllegalStateException(msg);
    }
    oauthHelper = new GoogleOAuthHelper(signer);
}
else if("HMAC-SHA1".equalsIgnoreCase(signerType))
{
    OAuthHmacSha1Signer signer = new OAuthHmacSha1Signer();
    oauthHelper = new GoogleOAuthHelper(signer);
}
else
{
    String msg = "Invalid Google OAuth Signer configured on property file";
    logger.error(msg);
    throw new IllegalArgumentException(msg);
}

try
{
    oauthHelper.getUnauthorizedRequestToken(googleOAuthParms);
}
catch (OAuthException ex)
{
    logger.error(ex.getMessage(), ex);
    Message msg = new MessageImpl(MessageType.ERROR, "error.authentication.oauth", ex.getMessage());
    response.add(msg);
    return response;
}
...

Original issue reported on code.google.com by rubens.s.gomes on 16 Jul 2010 at 1:14

GoogleCodeExporter commented 9 years ago
Any ideas or comments about this error?

Original comment by rubens.s.gomes on 9 Aug 2010 at 2:34

GoogleCodeExporter commented 9 years ago
This problem was due to incorrect timestamp on my Linux server.  My timestamp 
was 27 minutes behind what it should actually be.  I modified the date 
timestamp, and started the ntpd (network timing syncronization) daaemon.  And 
that fixed the issues I was having with Google OAuth 400 HTTP response error.

Again, if you have this problem where the exact same OAuth code works on one 
box, but does not work on another.  Please, *ensure* the timestamp of your 
other box is not too far from what it should be.

Thanks,

Rubens Gomes
http://www.rubens-gomes.com/

Try EZLista - A Simple and Easy Address Book  - It's Free!
http://www.ezlista.com/

Original comment by rubens.s.gomes on 12 Aug 2010 at 8:29

GoogleCodeExporter commented 9 years ago
Thanks for reporting your resolution.  Hopefully this helps anyone that 
encounters the same problem.

Original comment by yan...@google.com on 9 Sep 2010 at 6:42

GoogleCodeExporter commented 9 years ago
This comment was very helpful ... thanks to the good author!

Original comment by alvin.pa...@gmail.com on 11 Feb 2011 at 6:37