使用 Scribe for GWT 进行 oauth
我正在尝试为我的网络应用程序实现“Twitter”登录。我使用 scribe 来简化一些事情。
我的实现依赖于 GWT RPC 机制将授权 URL 返回给客户端,以便客户端可以调用弹出窗口来重定向到授权 URL。
但是,当 URL 打开新选项卡并且用户使用 Twitter 帐户登录时,页面会提供 PIN 码(来自此站点:https://api.twitter.com/oauth/authorize) 需要重新输入 org.scribe.model.Modifier
这种做法对于用户来说会很麻烦。需要的是,当用户输入 Twitter 用户名/密码时就应该是这样的。或者至少自动化所有其他过程。
我错过了什么吗?
这是我的代码:
twitterLogin.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
TwitterService.Util.getInstance().getAuthorizationUrl(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
if (result != null)
Window.open(result, "__blank", null);
}
@Override
public void onFailure(Throwable caught) {
}
});
}
});
I'm trying to implement "Twitter" login for my web application. I use scribe to simplify things a bit.
My implementation relies of GWT RPC mechanism to get the Authorization url back to the client so the client can call a popup window to redirect to the Autorization Url.
However, when the URL is opened to the new tab and user log in with Twitter account, the page provides the PIN number (from this site: https://api.twitter.com/oauth/authorize) that needs to be typed back into the org.scribe.model.Modifier
This kind of approach will be cumbersome to users. What is needed is that when the user typed in the Twitter username/password that should be it. Or at least automate all the other process.
Am I missing something?
Here's my code:
twitterLogin.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
TwitterService.Util.getInstance().getAuthorizationUrl(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
if (result != null)
Window.open(result, "__blank", null);
}
@Override
public void onFailure(Throwable caught) {
}
});
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用 OAuth 进行身份验证,您需要向身份验证服务器发送 2 个请求:
- 首先获得“请求令牌”
- 然后,为了获取“访问令牌”,
Twitter 会在新窗口中打开身份验证页面,他们可以在其中输入 Twitter 用户名/密码,因此这是可以预料的。
To authenticate with OAuth, you need to send out 2 requests to the authenticating server:
- First to get the "Request Token"
- Then to get the "Access Token"
Twitter does open the authentication page in a new window where they can type their Twitter username/password, so that's to be expected.