Twitter login not working

240 views
Skip to first unread message

Bruno Borges

unread,
Sep 13, 2013, 3:01:57 PM9/13/13
to socialau...@googlegroups.com
Hi all,

I have configured my application on Twitter using "http://127.0.0.1:8080" as the application url.
I have enabled the "Sign in with Twitter" option.
I have coded the following action command on JSF:

    public void socialAuth() throws Exception {
        Properties props = System.getProperties();
        props.put("twitter.com.consumer_key", "...");
        props.put("twitter.com.consumer_secret", "...");

        SocialAuthConfig config = SocialAuthConfig.getDefault();
        config.load(props);

        manager = new SocialAuthManager();
        manager.setSocialAuthConfig(config);

        ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
        String authurl = manager.getAuthenticationUrl("twitter", "http://127.0.0.1:8080");
        FacesContext.getCurrentInstance().getExternalContext().redirect(authurl);
    }

Still, I get the following error:

Caused by: org.brickred.socialauth.exception.SocialAuthConfigurationException: Application keys are not correct. The server running the application should be same that was registered to get the keys.
at org.brickred.socialauth.util.OAuthConsumer.getRequestToken(OAuthConsumer.java:206)
at org.brickred.socialauth.oauthstrategy.OAuth1.getLoginRedirectURL(OAuth1.java:69)
at org.brickred.socialauth.provider.TwitterImpl.getLoginRedirectURL(TwitterImpl.java:161)
at org.brickred.socialauth.SocialAuthManager.getAuthURL(SocialAuthManager.java:162)
at org.brickred.socialauth.SocialAuthManager.getAuthenticationUrl(SocialAuthManager.java:116)
at com.t.application.contexts.LoginContext.socialAuth(LoginContext.java:185)

Does anyone have a clue on why is this happening?

Thanks

Bruno Borges

unread,
Sep 13, 2013, 3:05:16 PM9/13/13
to socialau...@googlegroups.com
This is the DEBUG log of SocialAuth:

INFO:   8 16:03:24,900 DEBUG org.brickred.socialauth.SocialAuthManager - Getting Authentication URL for provider twitter, with success url : http://127.0.0.1:8080/
INFO:   8 16:03:24,900 INFO  org.brickred.socialauth.provider.TwitterImpl - Loading plugins
INFO:   8 16:03:24,900 INFO  org.brickred.socialauth.provider.TwitterImpl - Loading plugin :: org.brickred.socialauth.plugin.twitter.FeedPluginImpl
INFO:   9 16:03:24,901 INFO  org.brickred.socialauth.provider.TwitterImpl - Loading plugin :: org.brickred.socialauth.plugin.twitter.AlbumsPluginImpl
INFO:   9 16:03:24,901 INFO  org.brickred.socialauth.provider.TwitterImpl - Determining URL for redirection
INFO:   9 16:03:24,901 INFO  org.brickred.socialauth.oauthstrategy.OAuth1 - Determining URL for redirection
INFO:   9 16:03:24,901 DEBUG org.brickred.socialauth.oauthstrategy.OAuth1 - Call to fetch Request Token
INFO:   9 16:03:24,901 DEBUG org.brickred.socialauth.util.OAuthConsumer - Preparing to get Request Token
INFO:   9 16:03:24,901 DEBUG org.brickred.socialauth.util.OAuthConsumer - Given Request Token URL : https://api.twitter.com/oauth/request_token
INFO:   9 16:03:24,901 DEBUG org.brickred.socialauth.util.OAuthConsumer - Given CallBack URL : http://127.0.0.1:8080/
INFO:   10 16:03:24,902 DEBUG org.brickred.socialauth.util.OAuthConsumer - Generating OAUTH Signature
INFO:   10 16:03:24,902 DEBUG org.brickred.socialauth.util.OAuthConsumer - Given Signature Type : HMAC-SHA1
INFO:   10 16:03:24,902 DEBUG org.brickred.socialauth.util.OAuthConsumer - Given Method Type : GET
INFO:   10 16:03:24,902 DEBUG org.brickred.socialauth.util.OAuthConsumer - Given URL : https://api.twitter.com/oauth/request_token
INFO:   10 16:03:24,902 DEBUG org.brickred.socialauth.util.OAuthConsumer - Given Parameters : {oauth_callback=http://127.0.0.1:8080/, oauth_nonce=1379099004902, oauth_version=1.0, oauth_signature_method=HMAC-SHA1, oauth_consumer_key=2eAjpkTmQcwQpsJmUuA0A, oauth_timestamp=1379099004}
INFO:   16 16:03:24,908 DEBUG org.brickred.socialauth.util.OAuthConsumer - Signature data : GET&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252F127.0.0.1%253A8080%252F%26oauth_consumer_key%3D2eAjpkTmQcwQpsJmUuA0A%26oauth_nonce%3D1379099004902%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1379099004%26oauth_version%3D1.0
INFO:   16 16:03:24,908 DEBUG org.brickred.socialauth.util.OAuthConsumer - Encoding raw HMAC to Base64
INFO:   19 16:03:24,911 DEBUG org.brickred.socialauth.util.OAuthConsumer - HMAC-SHA1 Signature for request token : t/xKBsqGvPJX/TjZW2SoFxOV8jk=
INFO:   915 16:03:25,807 DEBUG org.brickred.socialauth.util.OAuthConsumer - Error while fetching Request Token
WARNING:   #{loginContext.socialConnect}: org.brickred.socialauth.exception.SocialAuthConfigurationException: Application keys are not correct. The server running the application should be same that was registered to get the keys.
javax.faces.FacesException: #{loginContext.socialConnect}: org.brickred.socialauth.exception.SocialAuthConfigurationException: Application keys are not correct. The server running the application should be same that was registered to get the keys.

Ken Yee

unread,
Sep 14, 2013, 4:27:26 PM9/14/13
to socialau...@googlegroups.com


On Friday, September 13, 2013 3:01:57 PM UTC-4, Bruno Borges wrote:
Caused by: org.brickred.socialauth.exception.SocialAuthConfigurationException: Application keys are not correct. The server running the application should be same that was registered to get the keys.

Are you sure you put in the right twitter keys?
Under their API console for your app, make sure you use the Oauth consumer key and consumer secret.  Don't use the access token if you created one.  I just did this today (added socialauth to dropwizard).

Twitter is annoying in other ways...e.g., the socialauth support doesn't set Firstname/Lastname from FullName (filed a socialauth bug on this).  And Twitter doesn't return your email address so you can use twitter oauth for identification.

Tarun Nagpal

unread,
Sep 18, 2013, 10:01:53 AM9/18/13
to socialau...@googlegroups.com

Do not use localhost for registering your application on twitter. You can use our demo keys for testing purpose.

Please have a look into following URL for more info
http://code.google.com/p/socialauth/wiki/HowToRunApplicationWithLocalhostOnWindows

For demo keys
http://code.google.com/p/socialauth/wiki/SampleProperties


 Key Yee -  Twitter only provide name and screen name. It doesn't provide FirstName and LastName. It is standard library for all providers so we set only those values which are given by provider.

You can split the Name value explicitly  to get the First Name and Last Name .


Regards
Tarun





Regards
Tarun

Ken Yee

unread,
Sep 18, 2013, 4:06:17 PM9/18/13
to socialau...@googlegroups.com


On Wednesday, September 18, 2013 10:01:53 AM UTC-4, Tarun Nagpal wrote:
 Key Yee -  Twitter only provide name and screen name. It doesn't provide FirstName and LastName. It is standard library for all providers so we set only those values which are given by provider.

You can split the Name value explicitly  to get the First Name and Last Name .

Yep...that's what I do in my code.  I filed that Issue thinking other people might want that done automatically in the socialauth code.
 
Reply all
Reply to author
Forward
0 new messages