How can I use twitter for sign in to my Codename o

2019-06-02 11:17发布

I am trying to sign in with twitter in my Codename one application, but when I am clicking on login button it will redirect to twitter, but not asking for credentials, It just throws a following error:

Whoa there! There is no request token for this page. That's the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

below is my code:

twitter.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {



                Oauth2 Tauth = new Oauth2("https://api.twitter.com/oauth/authenticate?oauth_token", "XXXXXXXXXXXXXXXXXX", "https://www.codenameone.com");
                Tauth.showAuthentication(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                    AccessToken token = (AccessToken) evt.getSource();
                    Log.p(token.toString());
                    }
                });

            }
        });

So anyone know whats wrong with this code?

1条回答
闹够了就滚
2楼-- · 2019-06-02 11:21

I haven't used twitter's API myself, but your URL looks incorrect. This docs page indicates that you should be using "https://api.twitter.com/oauth2/token".

And don't include a query string as part of the URL. Just the base URL "https://api.twitter.com/oauth2/token".

The Oauth2 class will add necessary query parameters.

查看更多
登录 后发表回答