如何在本地针对 OAuth 进行开发? [英] How do I develop against OAuth locally?

查看:44
本文介绍了如何在本地针对 OAuth 进行开发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个需要与 OAuth 服务提供者通信的 Python 应用程序.SP 要求我指定回调 URL.指定 localhost 显然不起作用.我无法设置面向公众的服务器.除了支付服务器/托管费用之外还有其他想法吗?这甚至可能吗?

I'm building a Python application that needs to communicate with an OAuth service provider. The SP requires me to specify a callback URL. Specifying localhost obviously won't work. I'm unable to set up a public facing server. Any ideas besides paying for server/hosting? Is this even possible?

推荐答案

两件事:

  1. 有问题的 OAuth 服务提供者违反了 OAuth 规范,如果您没有指定回调 URL,它会向您显示错误.callback_url 规范为可选参数.

但是,撇开迂腐不谈,您可能希望在用户完成后获得回调,以便您知道可以将请求令牌兑换为访问令牌.Yahoo 的 FireEagle 开发人员文档 提供了大量有关如何执行此操作的重要信息.

But, pedantry aside, you probably want to get a callback when the user's done just so you know you can redeem the Request Token for an Access Token. Yahoo's FireEagle developer docs have lots of great information on how to do this.

即使在第二种情况下,回调 URL 实际上根本不必在 Internet 上可见.OAuth 服务提供者会将用户用来提供其用户名/密码的浏览器重定向到回调 URL.

Even in the second case, the callback URL doesn't actually have to be visible from the Internet at all. The OAuth Service Provider will redirect the browser that the user uses to provide his username/password to the callback URL.

执行此操作的两种常用方法是:

The two common ways to do this are:

  1. 从您的应用程序中创建一个监听某个端口(例如,http://localhost:1234/) 用于完成回调,或
  2. 注册一个协议处理程序(您必须查看操作系统的文档,专门了解如何执行此类操作,但它可以使诸如 <a href="skype:555-1212"> 之类的东西工作).

(我相信您所描述的流程示例生活在这里.)

(An example of the flow that I believe you're describing lives here.)

这篇关于如何在本地针对 OAuth 进行开发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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