Pythonoath2
库的文档提供了一个非常简单的示例来说明如何向 Twitter 进行身份验证:
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
但是,如何指定额外的参数?例如,Facebook 需要“范围”参数来请求电子邮件地址等数据。此外,是否有使用除 Twitter 之外的其他提供商的示例,例如 Facebook 或 Google OAuth2?