开放认证协议OAuth -- 协议工作流程

OAuth协议致力于使网站和应用程序(统称为消费方)能够在无须用户透露其认证证书的情况下,通过API访问某个web服务(统称为服务提供方)的受保护资源。更一般地说,OAuth为API认证提供了一个可自由实现且通用的方法。

一个典型的例子是某打印服务提供商printer.example.com(消费方),希望在无须用户提供其照片存储站点密码的情况下,访问用户储存在photos.example.net(服务提供方)上的个人照片。

OAuth不强求一个特定的用户接口或操作模式,也不限定服务提供方如何验证用户,特别适合认证证书对消费方不可用的情况,例如OpenID。

OAuth致力于为托管web服务认证提供统一的体验和实现,形成一个社区驱动的协议。OAuth构建于已被多个站点独立实现的已有协议和最佳化实践之上,是一个被大小服务提供者所支持、并为应用开发者和用户增进持续性和可信度的开放标准。

  

OAuth is best explained with real-life examples. The specification  includes in Appendix A a similar example but focuses on the HTTP calls  syntax. This walk-through demonstrates a typical OAuth session and  includes the perspectives of the User, Consumer, and Service Provider.  The websites and people mentioned are fictional. The Scottish references  are real. And so our story begins…

OAuth最好使用真实生活中的例子来进行解释。OAuth规范的附录A中有一个与此相似的例子,但是它更关注HTTP调用的过程。这个例子在OAuth会话中是有代表性的,它包括了用户,消费者,服务提供者。这个例子中提到的人和网站都是虚构出来的不是真实的。关于苏格兰的引用是真实的。好了,让我们开始我们的故事吧。

  

Flow Step 1

Using OAuth terminology, Jane is the User and Faji the Service Provider. The 2 photos Jane uploaded are the Protected Resources.

使用OAuth的术语来描述一下,Jane是用户,Faji是服务提供者,Jane上传的两张照片是受保护的资源。

Flow Screen 1

Using OAuth terminology, Beppa is the Consumer. Since Jane marked the  photos as private, Beppa must use OAuth to gain access to the photos in  order to print them.

使用OAuth术语来描述一下,Beppa是消费者,自从Jane把她的照片标记为私有以后,Beppa必须使用OAuth来获取对这些私有图片的访问权以便把他们打印出来。

Flow Screen 2

When Beppa added support for Faji photo import, a Beppa developer  known in OAuth as a Consumer Developer obtained a Consumer Key and  Consumer Secret from Faji to be used with Faji’s OAuth-enabled API.

当Beppa添加支持从Faji导入图片的时候,一个Beppa开发者知道在OAuth中作为一个消费方开发者要从Faji获取消费Key和消费密钥以便使用Faji提供的OAuth认证API。

After Jane clicks Continue, something important happens in the  background between Beppa and Faji. Beppa requests from Faji a Request  Token. At this point, the Request Token is not User-specific, and can be  used by Beppa to gain User approval from Jane to access her private  photos.

当Jane点击了继续以后,一些重要的事情在Beppa和Faji之间发生了。Beppa从Faji请求了一个Request Token。用户对这个Request Token是不了解的,这个Request Token可以被Beppa来使用获取Jane的审批用来获取她的私有图片资源。

Flow Step 2

When Beppa receives the Request Token, it redirects Jane to the Faji  OAuth User Authorization URL with the Request Token and asks Faji to  redirect Jane back once approval has been granted to  http://beppa.com/order.

当Beppa接受到Request Token以后,Beppa拿着接收到的Request Token重定向Jane到Faji的OAuth用户授权URL并且要求Faji在完成用户授权以后重定向Jane到Http://beppa.com/order。

Jane has been redirected to Faji and is requested to sign into the  site. OAuth requires that Service Providers first authenticate the User,  and then ask them to grant access to the Consumer.

Jane被重定向到Faji并且被要求登录。OAuth要求服务提供者首先认证用户,认证完成之后要求用户批准消费者的访问。

Flow Screen 3

OAuth allows Jane to keep her username and password private and not  share them with Beppa or any other site. At no time does Jane enters her  credentials into beppa.com.

OAuth允许Jane保护她的用户和密码可以不分享给Beppa或任何其他的网站。Jane可以选择不输入她的用户名和密码进入beppa.com网站。

After successfully logging into Faji, Jane is asked to grant access  to Beppa, the Consumer. Faji informs Jane of who is requesting access  (in this case Beppa) and the type of access being granted. Jane can  approve or deny access.

成功登录进Faji以后,Jane被要求授权给Beppa这个消费者。Faji提醒Jane谁正在请求访问(在这里是Beppa)和需要授权访问的内容。Jane可以审批通过也可以拒绝这个访问。

Flow Screen 4

Once Jane approves the request, Faji marks the Request Token as  User-authorized by Jane. Jane’s browser is redirected back to Beppa, to  the URL previously provided http://beppa.com/order together with the  Request Token. This allows Beppa to know it can now continue to fetch  Jane’s photos.

一旦Jane审批通过了这个请求,Faji标记这个Request Token被Jane授权了。Jane的浏览器被重定向回到了Beppa,以前提供的URLhttp://beppa.com/order现在带有了Request Token。现在允许Beppa获取Jane的图片了,它可以继续执行它的打印操作了。

Flow Screen 5

While Jane waits, Beppa uses the authorized Request Token and  exchanges it for an Access Token. Request Tokens are only good for  obtaining User approval, while Access Tokens are used to access  Protected Resources, in this case Jane’s photos. In the first request,  Beppa exchanges the Request Token for an Access Token and in the second  (can be multiple requests, one for a list of photos, and a few more to  get each photo) request gets the photos.

当Jane等待的时候,Beppa使用这个授权的Request Token从Faji那里交换了一个Access Token。

Request Token用来获取用户的审批,而Access Token是被用来获取受保护的资源的,在这里指的是Jane的图片。在第一个请求中,Beppa拿Request Token换取了一个Access Token,在第二个请求(可以是多个请求,每一个都获取若干个图片)中来得到图片。

Flow Step 3

When Beppa is done, Jane’s browser refreshes to complete the order.

Beppa successfully fetched Jane’s photo. They are presented as thumbnails for her to pick and place her order.

当Bepa完成的时候,jane的浏览器重新刷新来完成这次下单。

Beppa成功的获取了Jane的图片。Beppa获取了图片并处理成了缩略图下单完成了。

Flow Screen 6
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值