本文整理汇总了Python中oauth2client._helpers.parse_unique_urlencoded方法的典型用法代码示例。如果您正苦于以下问题:Python _helpers.parse_unique_urlencoded方法的具体用法?Python _helpers.parse_unique_urlencoded怎么用?Python _helpers.parse_unique_urlencoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauth2client._helpers
的用法示例。
在下文中一共展示了_helpers.parse_unique_urlencoded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_GET
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import parse_unique_urlencoded [as 别名]
def do_GET(self):
"""Handle a GET request.
Parses the query parameters and prints a message
if the flow has completed. Note that we can't detect
if an error occurred.
"""
self.send_response(http_client.OK)
self.send_header('Content-type', 'text/html')
self.end_headers()
parts = urllib.parse.urlparse(self.path)
query = _helpers.parse_unique_urlencoded(parts.query)
self.server.query_params = query
self.wfile.write(
b'<html><head><title>Authentication Status</title></head>')
self.wfile.write(
b'<body><p>The authentication flow has completed.</p>')
self.wfile.write(b'</body></html>')
示例2: _parse_exchange_token_response
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import parse_unique_urlencoded [as 别名]
def _parse_exchange_token_response(content):
"""Parses response of an exchange token request.
Most providers return JSON but some (e.g. Facebook) return a
url-encoded string.
Args:
content: The body of a response
Returns:
Content as a dictionary object. Note that the dict could be empty,
i.e. {}. That basically indicates a failure.
"""
resp = {}
content = _helpers._from_bytes(content)
try:
resp = json.loads(content)
except Exception:
# different JSON libs raise different exceptions,
# so we just do a catch-all here
resp = _helpers.parse_unique_urlencoded(content)
# some providers respond with 'expires', others with 'expires_in'
if resp and 'expires' in resp:
resp['expires_in'] = resp.pop('expires')
return resp
示例3: test_without_repeats
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import parse_unique_urlencoded [as 别名]
def test_without_repeats(self):
content = 'a=b&c=d'
result = _helpers.parse_unique_urlencoded(content)
self.assertEqual(result, {'a': 'b', 'c': 'd'})
示例4: test_with_repeats
# 需要导入模块: from oauth2client import _helpers [as 别名]
# 或者: from oauth2client._helpers import parse_unique_urlencoded [as 别名]
def test_with_repeats(self):
content = 'a=b&a=d'
with self.assertRaises(ValueError):
_helpers.parse_unique_urlencoded(content)