在 Django 中编写两条腿的 OAuth 提供程序
我正在寻找有关在 Django 中为 OAuth 编写两条腿的提供程序的教程/示例/说明。
很难找到有关 OAuth 提供程序的文档,更难找到有关两条腿系统的文档......
I'm looking for a tutorial/example/explanation about writing a two-legged provider for OAuth in Django.
It's hard to find documentation about a OAuth provider, and even harder about a two-legged system...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我花了大约 3 天的时间试图解决这个问题,并希望为任何可以使用它的人提供这个我最终从我试图查询的服务中获得的工作示例。结果非常容易。 PS 仅仅因为有人使用 oauth 1.0 并不就意味着您不能使用 oauth2 库。
要获取 auth2,请输入 pip install oauth2。
在您的脚本中,您需要:
调用该函数并查看输出如下所示:
I spent about 3 days trying to figure this out and wanted to provide anyone who can use it with this working example I finally got from the service I was trying to query. It wound up being extremely easy. P.S. Just because someone is using oauth 1.0 doesn't mean that you can't use the oauth2 library.
To get auth2, type pip install oauth2.
In your script, you need:
Calling the function and viewing the output looks like this:
“2legged”只是普通的 OAuth 请求,没有访问令牌或访问令牌机密。就是这样。您仍然使用客户端凭据(标识符和密钥),但使用空字符串作为访问令牌参数。根据您使用的服务器库,您可以在发出请求时省略 oauth_token 参数。
'2 legged' is just normal OAuth request without an access token or access token secret. That's it. You still use the client credentials (identifier and secret) but use empty strings for the access token parameters. Depending on the server library you use, you can omit the oauth_token parameter when making the request.
这是一篇很好的入门文章: http://philipsoutham.com/post/ 2172924723/two-legged-oauth-in-python
活塞的两腿 OAuth:https://github.com/gregbayer/django-piston-two-legged-oauth
This is a good starting article: http://philipsoutham.com/post/2172924723/two-legged-oauth-in-python
Two-legged OAuth for Piston: https://github.com/gregbayer/django-piston-two-legged-oauth