如何使用twitter登录我的Codename one应用程序 [英] How can I use twitter for sign in to my Codename one application
问题描述
我正试图在我的Codename一个应用程序中使用twitter登录,但是当我点击登录按钮时,它将重定向到Twitter,但不会要求凭据,它只会引发以下错误:
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:
哇哇!
此页面没有请求令牌。这是我们要求使用您的Twitter帐户的应用程序所需的特殊密钥。请返回发送给您的网站或应用程序,然后重试;这可能只是一个错误。
下面是我的代码:
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?
推荐答案
我自己没有使用过twitter的API,但是你的网址看起来不对。 此文档页面表明您应该使用 https://api.twitter.com/oauth2/token 。
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".
并且不要将查询字符串包含在URL中。只需基本网址 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".
Oauth2
类将添加必要的查询参数。
The Oauth2
class will add necessary query parameters.
这篇关于如何使用twitter登录我的Codename one应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!