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?
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.