我的申请的Twitter api授权 [英] Twitter api authorization of my application

查看:854
本文介绍了我的申请的Twitter api授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个 twitter api库,到目前为止一切都很棒。我的问题(用户体验不是真正的问题)是每次你想用twitter登录时都需要打开一个弹出窗口。

I am using this twitter api library and so far everything is great. My problem (well not really a problem more a user experience) is that every time you want to sign in with twitter you need to open a popup.

目前流程是这样的:


  • 用户点击登录在我的页面上有推特标识。

  • Javascript引发的弹出窗口出现了Twitter上的Oauth内容。如果您已登录,则表示登录并取消。如果你不是,它有登录字段。

  • 如果一切顺利,它会转到我提供的回调网址。做一堆东西,然后.. ..

  • 我调用window.opener并传递经过身份验证的信息,然后关闭窗口。

  • User clicks on the sign in with twitter logo on my page.
  • Javascript induced popup comes up with the the twitter Oauth stuff on it. If you are logged in all it says is login and cancel. If you are not it has login fields.
  • If everything is good it goes to a callback url that I supply. does a bunch of stuff and then..
  • I call window.opener and pass the authenticated info and from there I close the window.

这实际上很容易实现并且效果很好。我想知道twiiter登录过程是否会像facebook那样更像。

This was surprisingly easy to implement and works great. I'm wondering if the twiiter login process can be a little more like the facebooks which would be this.


  • 用户点击登录我的页面上有twitter徽标。

  • 如果用户已登录并已自动启动应用程序,弹出窗口将弹出窗口立即消失并将用户数据丢回我的页面。

我确实知道我正在使用一个php库用于推特和facebook流程来自javascript方面,但我想知道我是否可以检测到,使用php,如果用户已经允许该应用程序并已登录,则为他们绕过额外的登录/取消点击。

I do realize that I am using a php library for twitter and the facebook flow is from the javascript side but I am wondering if I can detect, with php, if the user has already allowed the app and is signed in, for them bypass the extra signin/cancel click.

推荐答案

尝试使用使用Twitter登录流程。如果用户已经过身份验证,则只需单击操作即可。上面的链接文档有一个流程图和流程描述,但我会列出这里的步骤(强调添加),并链接到相关的API页面:

Try using the "Sign in with Twitter" flow. If the user is already authenticated, it's a one click operation. The linked doc above has a flowchart and description of the process, but I'll list the steps here (with emphasis added) as well, and link in the relevant API pages:


使用Twitter登录是模式
的身份验证,允许用户将
连接他们的Twitter帐户与
第三次 - 派对服务只需点击一下。它使用OAuth和
虽然流程非常相似,但
授权URL和工作流程略有不同,如下所述。

"Sign in with Twitter" is the pattern of authentication that allows users to connect their Twitter account with third-party services in as little as one click. It utilizes OAuth and although the flow is very similar, the authorization URL and workflow differs slightly as described below.


正常流程规定应用程序
将请求令牌发送到 oauth / authorize
OAuth规范在Twitter中实现
。为了利用
使用Twitter登录,
应用程序应该将 oauth_token
参数中收到的请求
令牌发送到 oauth / authenticate

The normal flow dictates that applications send request tokens to oauth/authorize in Twitter's implementation of the OAuth Specification. To take advantage of "Sign in with Twitter", applications should send request tokens received in the oauth_token parameter to oauth/authenticate instead.

oauth / authenticate 方法
将以不同的方式行事,具体取决于
用户状态及其
之前与调用
应用程序的交互:

The oauth/authenticate method will act in different ways depending on the status of the user and their previous interaction with the calling application:


  1. 如果用户登录到
    到twitter已经
    批准了调用应用程序,
    用户将立即通过身份验证
    并返回到回调URL。

  1. If the user is logged into twitter.com and has already approved the calling application, the user will be immediately authenticated and returned to the callback URL.

如果
用户未登录
twitter.com且已经批准
调用应用程序,则用户将
提示登录twitter.com
然后将立即验证
并返回到回调URL。

If the user is not logged into twitter.com and has already approved the calling application, the user will be prompted to login to twitter.com then will be immediately authenticated and returned to the callback URL.

如果
用户登录到twitter.com
并且尚未批准
调用应用程序,则OAuth
授权提示将为
。授权用户然后将
重定向到回调URL。

If the user is logged into twitter.com and has not already approved the calling application, the OAuth authorization prompt will be presented. Authorizing users will then be redirected to the callback URL.

如果
用户未登录
twitter.com且尚未通过
批准调用应用程序,
用户将被提示登录
twitter.com然后将在
重定向回到回调URL之前显示
授权提示。

If the user is not logged into twitter.com and has not already approved the calling application, the user will be prompted to login to twitter.com then will be presented the authorization prompt before redirecting back to the callback URL.


希望这符合账单并适合您。

Hopefully this fits the bill and will work for you.

这篇关于我的申请的Twitter api授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆