本文整理汇总了Python中urllib2.Request.headers['Authorization']方法的典型用法代码示例。如果您正苦于以下问题:Python Request.headers['Authorization']方法的具体用法?Python Request.headers['Authorization']怎么用?Python Request.headers['Authorization']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib2.Request
的用法示例。
在下文中一共展示了Request.headers['Authorization']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_data
# 需要导入模块: from urllib2 import Request [as 别名]
# 或者: from urllib2.Request import headers['Authorization'] [as 别名]
def user_data(self, access_token):
"""Loads user data data from googleapis service, only email so far
as it's described in:
http://sites.google.com/site/oauthgoog/Home/emaildisplayscope
OAuth parameters needs to be passed in the queryset and
Authorization header, this behavior is listed in:
http://groups.google.com/group/oauth/browse_thread/thread/d15add9beb418ebc
"""
url = self.oauth_request(access_token, GOOGLEAPIS_EMAIL,
{'alt': 'json'}).to_url()
params = url.split('?', 1)[1]
request = Request(url)
request.headers['Authorization'] = params # setup header
response = urlopen(request).read()
try:
return simplejson.loads(response)['data']
except (simplejson.JSONDecodeError, KeyError):
return None