本文介绍了适用于App Engine的OAuth2客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以在一个好的图书馆中给我建议,或者如何开始使用基于Python的基于API的应用程序来使用OAuth来验证另一台服务器?我有一个应用程序在期望用户输入的appengine上。我希望用户能够上传图片,我将它放在 imgur.com 中,并且能够在用户的页面上显示给用户。为了能够做到这一点,我需要能够验证到api.imgur.com因此问题。
解决方案
有看项目。
客户端示例:
将oauth2导入为oauth
#使用正确的密钥/秘密创建消费者。
consumer = oauth.Consumer(key =your-twitter-consumer-key,
secret =your-twitter-consumer-secret)
#请求令牌URL为Twitter。
request_token_url =http://twitter.com/oauth/request_token
#创建我们的客户。
client = oauth.Client(consumer)
#OAuth Client请求的工作方式与httplib2大致相同。
resp,content = client.request(request_token_url,GET)
print resp
打印内容
Can anyone advice me on a good library or else how to go about having a Python appengine based application using OAuth to authenticate to another server?
I have an application on appengine that expects user input. I would like the user to be able to upload an image, which I would put in imgur.com and would be able to show to the user back on my page. To be able to do that, I need to be able to authenticate to api.imgur.com hence the question.
解决方案
Have a look to python-oauth2 project.
A Client example:
import oauth2 as oauth
# Create your consumer with the proper key/secret.
consumer = oauth.Consumer(key="your-twitter-consumer-key",
secret="your-twitter-consumer-secret")
# Request token URL for Twitter.
request_token_url = "http://twitter.com/oauth/request_token"
# Create our client.
client = oauth.Client(consumer)
# The OAuth Client request works just like httplib2 for the most part.
resp, content = client.request(request_token_url, "GET")
print resp
print content
这篇关于适用于App Engine的OAuth2客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!