Mrjndong / socialauth

Automatically exported from code.google.com/p/socialauth
0 stars 0 forks source link

SocialAuth working for Facebook and Google, the rest: SocialAuthException: Unable to retrieve the access token #184

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Created apps and got keys for FB,Google,Yahoo,Twitter and LinkedIn
2.Put tjey keys in the conf file
3.Created my login buttons

What is the expected output? What do you see instead?
I shoul be able to end up in a register form with all of the 5

What version of the product are you using? On what operating system?
not relevant I think

Please provide any additional information below.
I am pretty sure the twitter and linkedIn worked once. Now they will all the 
time return this SocialAuthException: Unable to retrieve the access token when 
calling:

AuthProvider provider = 
me.getAuthManager().connect(SocialAuthUtil.getRequestParametersMap(request));

as I said, it works perfectly with Google and Facebook.

BTW, Amazing Work!! well done!!

Original issue reported on code.google.com by gomezrei...@gmail.com on 11 Jun 2012 at 9:00

GoogleCodeExporter commented 8 years ago
Hi

Can you please send complete log by running your application in DEBUG logger 
option.

Regards
Tarun

Original comment by tar...@brickred.com on 12 Jun 2012 at 8:31

GoogleCodeExporter commented 8 years ago
Tarun,

thanks for such a quick reply.

[#|2012-06-12T09:42:14.367+0000|INFO|glassfish3.1.2|org.brickred.socialauth.oaut
hstrategy.OAuth1|_ThreadID=24;_ThreadName=Thread-2;|Redirection to following 
URL should happen : 
https://api.linkedin.com/uas/oauth/authenticate?oauth_token=4d214aeb-ee1a-4169-8
661-e14618ad169b&oauth_callback=http%3A%2F%2F<HERE_I_HAVE_A_REAL_DOMAIN>%2Fdoing
-web%2Fauth%3Fprovider%3Dlinkedin|#]

[#|2012-06-12T09:43:20.862+0000|INFO|glassfish3.1.2|org.brickred.socialauth.Soci
alAuthManager|_ThreadID=25;_ThreadName=Thread-2;|Connecting provider : 
linkedin|#]

[#|2012-06-12T09:43:20.862+0000|INFO|glassfish3.1.2|org.brickred.socialauth.prov
ider.LinkedInImpl|_ThreadID=25;_ThreadName=Thread-2;|Verifying the 
authentication response from provider|#]

[#|2012-06-12T09:43:20.862+0000|INFO|glassfish3.1.2|org.brickred.socialauth.oaut
hstrategy.OAuth1|_ThreadID=25;_ThreadName=Thread-2;|Verifying the 
authentication response from provider|#]

[#|2012-06-12T09:43:20.935+0000|SEVERE|glassfish3.1.2|com.doing.servlets.Auth|_T
hreadID=25;_ThreadName=Thread-2;|org.brickred.socialauth.exception.SocialAuthExc
eption: Unable to retrieve the access token. Status: 401
        at org.brickred.socialauth.util.OAuthConsumer.getAccessToken(OAuthConsumer.java:251)
        at org.brickred.socialauth.oauthstrategy.OAuth1.verifyResponse(OAuth1.java:96)
        at org.brickred.socialauth.oauthstrategy.OAuth1.verifyResponse(OAuth1.java:106)
        at org.brickred.socialauth.provider.LinkedInImpl.doVerifyResponse(LinkedInImpl.java:171)
        at org.brickred.socialauth.provider.LinkedInImpl.verifyResponse(LinkedInImpl.java:165)
        at org.brickred.socialauth.SocialAuthManager.connect(SocialAuthManager.java:183)
        at com.doing.servlets.Auth.doGet(Auth.java:77)
        ...................................

I was actually starting to wonder if this could be realted to the fact that 
this is running in an Amazon EC2 server....

Original comment by i...@geodoing.com on 12 Jun 2012 at 9:46

GoogleCodeExporter commented 8 years ago
Sorry Tarun,
that should have shown a different logging level. It did in development. I will 
try to figure out why the prod logger is not doing the job. 

Cheers

Original comment by i...@geodoing.com on 12 Jun 2012 at 12:55

GoogleCodeExporter commented 8 years ago
Tarun, sorry for the late reply. There really seem to be a problem with the GF 
we run in prod enabling the log. Anyway, I followed your advice on how to run 
it locally by changing the host file and manager to reproduce in my local 
Glassfish where the logger enables properly. Following the reply. I do actually 
see some suspicious providerid=null not sure this is the problem. Any help 
would be higly apreciated:

FINE: Getting Authentication URL for provider twitter, with success url : 
http://geodoing.com/doing-web/auth?provider=twitter
FINE: Permission requested : all
INFO: Determining URL for redirection
INFO: Determining URL for redirection
FINE: Call to fetch Request Token
FINE: Preparing to get Request Token
FINE: Given Request Token URL : http://api.twitter.com/oauth/request_token
FINE: Given CallBack URL : http://geodoing.com/doing-web/auth?provider=twitter
FINE: Generating OAUTH Signature
FINE: Given Signature Type : HMAC-SHA1
FINE: Given Method Type : GET
FINE: Given URL : http://api.twitter.com/oauth/request_token
FINE: Given Parameters : 
{oauth_callback=http://geodoing.com/doing-web/auth?provider=twitter, 
oauth_nonce=1339617030088, oauth_version=1.0, oauth_signature_method=HMAC-SHA1, 
oauth_consumer_key=M2fKQs5zGdXksygoIPdGwA, oauth_timestamp=1339617030}
FINE: Signature data : 
GET&http%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%2
53A%252F%252Fgeodoing.com%252Fdoing-web%252Fauth%253Fprovider%253Dtwitter%26oaut
h_consumer_key%3DM2fKQs5zGdXksygoIPdGwA%26oauth_nonce%3D1339617030088%26oauth_si
gnature_method%3DHMAC-SHA1%26oauth_timestamp%3D1339617030%26oauth_version%3D1.0
FINE: Encoding raw HMAC to Base64
FINE: HMAC-SHA1 Signature for request token : XOS0cD6VMlwiihnHWnn+tg7/MbQ=
FINE: URL to get Request Token : 
http://api.twitter.com/oauth/request_token?oauth_callback=http%3A%2F%2Fgeodoing.
com%2Fdoing-web%2Fauth%3Fprovider%3Dtwitter&oauth_consumer_key=M2fKQs5zGdXksygoI
PdGwA&oauth_nonce=1339617030088&oauth_signature=XOS0cD6VMlwiihnHWnn%2Btg7%2FMbQ%
3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1339617030&oauth_version=1.0
FINE: KEY : IYdmxISTZg7xvGdSGubhvu8l0FadhbJJo4g1dH2dhwc
FINE: SECRET : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
INFO: Redirection to following URL should happen : 
https://api.twitter.com/oauth/authorize?oauth_token=IYdmxISTZg7xvGdSGubhvu8l0Fad
hbJJo4g1dH2dhwc&oauth_callback=http%3A%2F%2Fgeodoing.com%2Fdoing-web%2Fauth%3Fpr
ovider%3Dtwitter
INFO: org.apache.catalina.connector.RequestFacade@6d9cef21
INFO: Connecting provider : twitter
INFO: Verifying the authentication response from provider
INFO: Verifying the authentication response from provider
FINE: Call to fetch Access Token
FINE: Preparing to get Access Token
FINE: Given Access Token URL : https://api.twitter.com/oauth/access_token
FINE: Given Request Token : org.brickred.socialauth.util.AccessGrant Object {
 token key : IYdmxISTZg7xvGdSGubhvu8l0FadhbJJo4g1dH2dhwc
 token secret : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
provider id : null
permission : null
{oauth_callback_confirmed=true, 
oauth_verifier=dqYaWXI7Vrm8rPO1lhwiTEHWCEguf7QEWI9tv8C0Mig}}
FINE: Generating OAUTH Signature
FINE: Given Signature Type : HMAC-SHA1
FINE: Given Method Type : GET
FINE: Given URL : https://api.twitter.com/oauth/access_token
FINE: Given Parameters : {oauth_nonce=1339617030745, oauth_version=1.0, 
oauth_signature_method=HMAC-SHA1, oauth_consumer_key=M2fKQs5zGdXksygoIPdGwA, 
oauth_token=IYdmxISTZg7xvGdSGubhvu8l0FadhbJJo4g1dH2dhwc, 
oauth_verifier=dqYaWXI7Vrm8rPO1lhwiTEHWCEguf7QEWI9tv8C0Mig, 
oauth_timestamp=1339617030}
FINE: Signature data : 
GET&https%3A%2F%2Fapi.twitter.com%2Foauth%2Faccess_token&oauth_consumer_key%3DM2
fKQs5zGdXksygoIPdGwA%26oauth_nonce%3D1339617030745%26oauth_signature_method%3DHM
AC-SHA1%26oauth_timestamp%3D1339617030%26oauth_token%3DIYdmxISTZg7xvGdSGubhvu8l0
FadhbJJo4g1dH2dhwc%26oauth_verifier%3DdqYaWXI7Vrm8rPO1lhwiTEHWCEguf7QEWI9tv8C0Mi
g%26oauth_version%3D1.0
FINE: Encoding raw HMAC to Base64
FINE: HMAC-SHA1 Signature for access token : j3JhuBPjIYwZSN6EYf8AQyqZx9c=
FINE: Access Token URL : 
https://api.twitter.com/oauth/access_token?oauth_consumer_key=M2fKQs5zGdXksygoIP
dGwA&oauth_nonce=1339617030745&oauth_signature=j3JhuBPjIYwZSN6EYf8AQyqZx9c%3D&oa
uth_signature_method=HMAC-SHA1&oauth_timestamp=1339617030&oauth_token=IYdmxISTZg
7xvGdSGubhvu8l0FadhbJJo4g1dH2dhwc&oauth_verifier=dqYaWXI7Vrm8rPO1lhwiTEHWCEguf7Q
EWI9tv8C0Mig&oauth_version=1.0
SEVERE: The log message is null.
org.brickred.socialauth.exception.SocialAuthException: Unable to retrieve the 
access token. Status: 401

Original comment by i...@geodoing.com on 13 Jun 2012 at 7:57

GoogleCodeExporter commented 8 years ago
Cay you please quickly check your server time. Is it match with current time.
Or you can provide me a domain and key/secret so I can check it locally at my 
end, if possible for you.

Regards
Tarun

Original comment by tar...@brickred.com on 14 Jun 2012 at 2:17

GoogleCodeExporter commented 8 years ago
Hello, 

you mean if I can give you the secret for twitter app for example? Sure, no 
problem here it goes:

Consumer key    M2fKQs5zGdXksygoIPdGwA
Consumer secret     9pOr84YUOD5437KyS8IpB08c7vZkB5iV70GPQ8F97qc

Original comment by i...@geodoing.com on 14 Jun 2012 at 2:37

GoogleCodeExporter commented 8 years ago
domain would be geodoing.com

Original comment by i...@geodoing.com on 14 Jun 2012 at 2:37

GoogleCodeExporter commented 8 years ago
server time: Thu Jun 14 14:40:32 UTC 2012

its Amazon EC2 (I think in US)

Original comment by i...@geodoing.com on 14 Jun 2012 at 2:41

GoogleCodeExporter commented 8 years ago
But Tarun, dont you need as well to implement a servlet for the return callback?

Callback URL    http://geodoing.com/doing-web/auth

You surely know better than me!!

Thank you

Original comment by i...@geodoing.com on 14 Jun 2012 at 2:53

GoogleCodeExporter commented 8 years ago
Hello Tarun,

Is it ok that the providerid in the auth object is null? 

FINE: Given Request Token : org.brickred.socialauth.util.AccessGrant Object {
 token key : hktttsw
 token secret : 6461e4ad3aff5da94e000a1a6d703e819538287a
provider id : null
permission : null
{oauth_expires_in=3600, oauth_callback_confirmed=true, 
xoauth_request_auth_url=https://api.login.yahoo.com/oauth/v2/request_auth?oauth_
token=hktttsw, oauth_verifier=b52hkh}}

This above was yahoo (not working as well) and again provider id: null

thanks

Original comment by i...@geodoing.com on 15 Jun 2012 at 8:37

GoogleCodeExporter commented 8 years ago
Hi

Yes, it will show provider id null while requesting access token, this is not a 
problem.

And for yahoo please verify you have selected at least one permission while 
registering your application.

As I said before to check server time, my mean was your server clock time 
should match with current time. It should not be behind or ahead respective to 
current time.

Regards
Tarun

Original comment by tarunnag...@gmail.com on 15 Jun 2012 at 8:14

GoogleCodeExporter commented 8 years ago
well sorry for making you lose your time. I was doing the things quite wrong. 
We did in fact call twice in our code to 

manager.getAuthenticationUrl(....

once in the action and a second time in the success url. This somehow was ok 
for facebook and google but not for the other 3 providers we tried.

Fixed now.

Great library!!

Original comment by i...@geodoing.com on 21 Jun 2012 at 4:07

GoogleCodeExporter commented 8 years ago

Original comment by tar...@brickred.com on 16 Aug 2012 at 4:57