本文整理匯總了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)