本文整理汇总了Python中social.p3.urlencode函数的典型用法代码示例。如果您正苦于以下问题:Python urlencode函数的具体用法?Python urlencode怎么用?Python urlencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlencode函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: oauth_authorization_request
def oauth_authorization_request(self, token):
params = self.setting('AUTH_EXTRA_ARGUMENTS', {}).copy()
params.update({
'consumer_id': settings.SOCIAL_AUTH_PINTEREST_KEY,
'response_type': self.RESPONSE_TYPE,
})
return '{0}?{1}'.format(self.authorization_url(), urlencode(params))
开发者ID:scailer,项目名称:django-social-publisher,代码行数:7,代码来源:pinterest.py
示例2: auth_url
def auth_url(self):
"""Return redirect url"""
if self.STATE_PARAMETER or self.REDIRECT_STATE:
# Store state in session for further request validation. The state
# value is passed as state parameter (as specified in OAuth2 spec),
# but also added to redirect, that way we can still verify the
# request if the provider doesn't implement the state parameter.
# Reuse token if any.
name = self.name + '_state'
state = self.strategy.session_get(name)
if state is None:
state = self.state_token()
self.strategy.session_set(name, state)
else:
state = None
params = self.auth_params(state)
params.update(self.get_scope_argument())
params.update(self.auth_extra_arguments())
params = urlencode(params)
if not self.REDIRECT_STATE:
# redirect_uri matching is strictly enforced, so match the
# providers value exactly.
params = unquote(params)
return self.AUTHORIZATION_URL + '?' + params
开发者ID:AndrewJHart,项目名称:python-social-auth,代码行数:25,代码来源:oauth.py
示例3: auth_url
def auth_url(self):
"""Return authorization redirect url."""
key, secret = self.get_key_and_secret()
callback = self.strategy.absolute_uri(self.redirect_uri)
callback = sub(r'^https', 'http', callback)
query = urlencode({'cb': callback})
return 'https://www.twilio.com/authorize/{0}?{1}'.format(key, query)
开发者ID:AppsFuel,项目名称:python-social-auth,代码行数:7,代码来源:twilio.py
示例4: url_add_parameters
def url_add_parameters(url, params):
"""Adds parameters to URL, parameter will be repeated if already present"""
if params:
fragments = list(urlparse(url))
fragments[4] = urlencode(parse_qsl(fragments[4]) + params.items())
url = urlunparse(fragments)
return url
开发者ID:simonair,项目名称:python-social-auth,代码行数:7,代码来源:utils.py
示例5: user_data
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
user_id_url = kwargs.get('response').get('id')
url = user_id_url + '?' + urlencode({'access_token': access_token})
try:
return self.get_json(url)
except ValueError:
return None
开发者ID:AlinaKay,项目名称:python-social-auth,代码行数:8,代码来源:salesforce.py
示例6: revoke_token
def revoke_token(self, token, uid):
if self.REVOKE_TOKEN_URL:
url = self.revoke_token_url(token, uid)
params = self.revoke_token_params(token, uid)
headers = self.revoke_token_headers(token, uid)
data = urlencode(params) if self.REVOKE_TOKEN_METHOD != "GET" else None
response = self.request(url, params=params, headers=headers, data=data, method=self.REVOKE_TOKEN_METHOD)
return self.process_revoke_token_response(response)
开发者ID:JonesChi,项目名称:python-social-auth,代码行数:8,代码来源:oauth.py
示例7: url_add_parameters
def url_add_parameters(url, params):
"""Adds parameters to URL, parameter will be repeated if already present"""
if params:
fragments = list(urlparse(url))
value = parse_qs(fragments[4])
value.update(params)
fragments[4] = urlencode(value)
url = urlunparse(fragments)
return url
开发者ID:2070616d,项目名称:TP3,代码行数:9,代码来源:utils.py
示例8: oauth_authorization_request
def oauth_authorization_request(self, token):
"""Generate OAuth request to authorize token."""
if not isinstance(token, dict):
token = parse_qs(token)
params = self.auth_extra_arguments() or {}
params.update(self.get_scope_argument())
params['oauth_token'] = token.get('oauth_token')
params['redirect_uri'] = self.redirect_uri
return self.AUTHORIZATION_URL + '?' + urlencode(params)
开发者ID:simonair,项目名称:python-social-auth,代码行数:9,代码来源:oauth.py
示例9: oauth_authorization_request
def oauth_authorization_request(self, token):
"""Generate OAuth request to authorize token."""
if not isinstance(token, dict):
token = parse_qs(token)
params = self.auth_extra_arguments() or {}
params.update(self.get_scope_argument())
params[self.OAUTH_TOKEN_PARAMETER_NAME] = token.get(self.OAUTH_TOKEN_PARAMETER_NAME)
state = self.get_or_create_state()
params[self.REDIRECT_URI_PARAMETER_NAME] = self.get_redirect_uri(state)
return "{0}?{1}".format(self.authorization_url(), urlencode(params))
开发者ID:JonesChi,项目名称:python-social-auth,代码行数:10,代码来源:oauth.py
示例10: oauth_authorization_request
def oauth_authorization_request(self, token):
"""Generate OAuth request to authorize token."""
if not isinstance(token, dict):
token = parse_qs(token)
params = self.auth_extra_arguments() or {}
params.update(self.get_scope_argument())
params[self.OAUTH_TOKEN_PARAMETER_NAME] = token.get(
self.OAUTH_TOKEN_PARAMETER_NAME
)
params[self.REDIRECT_URI_PARAMETER_NAME] = self.redirect_uri
return self.AUTHORIZATION_URL + '?' + urlencode(params)
开发者ID:AndrewJHart,项目名称:python-social-auth,代码行数:11,代码来源:oauth.py
示例11: auth_url
def auth_url(self):
"""Return redirect url"""
state = self.get_or_create_state()
params = self.auth_params(state)
params.update(self.get_scope_argument())
params.update(self.auth_extra_arguments())
params = urlencode(params)
if not self.REDIRECT_STATE:
# redirect_uri matching is strictly enforced, so match the
# providers value exactly.
params = unquote(params)
return '{0}?{1}'.format(self.authorization_url(), params)
开发者ID:AlinaKay,项目名称:python-social-auth,代码行数:12,代码来源:oauth.py
示例12: auth_url
def auth_url(self):
"""Return redirect url"""
state = self.get_or_create_state()
params = self.auth_params(state)
params.update(self.get_scope_argument())
params.update(self.auth_extra_arguments())
params = urlencode(params)
if not self.REDIRECT_STATE:
# redirect_uri matching is strictly enforced, so match the
# providers value exactly.
params = unquote(params)
return self.AUTHORIZATION_URL + '?' + params
开发者ID:Akanksha18,项目名称:Amipool,代码行数:12,代码来源:oauth.py
示例13: refresh_token
def refresh_token(self, token, *args, **kwargs):
# python-social-auth doesn't give the right hooks to override just the url when refreshing the token
# so we need to copy over the whole method.
scope_params = urlencode(self.get_scope_argument())
params = self.refresh_token_params(token, *args, **kwargs)
# Wave's Oauth2 implementation requires that you send the scope as a URL paramater when refreshing the
# token - this is a bug in their system.
url = '{url}?{params}'.format(url=self.REFRESH_TOKEN_URL or self.ACCESS_TOKEN_URL, params=scope_params)
method = self.REFRESH_TOKEN_METHOD
key = 'params' if method == 'GET' else 'data'
request_args = {'headers': self.auth_headers(), 'method': method, key: params}
request = self.request(url, **request_args)
return self.process_refresh_token_response(request, *args, **kwargs)
开发者ID:ashchristopher,项目名称:python-social-auth-waveapps,代码行数:14,代码来源:backends.py
示例14: auth_url
def auth_url(self):
"""Return redirect url"""
state = None
if self.STATE_PARAMETER or self.REDIRECT_STATE:
# Store state in session for further request validation. The state
# value is passed as state parameter (as specified in OAuth2 spec),
# but also added to redirect_uri, that way we can still verify the
# request if the provider doesn't implement the state parameter.
# Reuse token if any.
name = self.name + "_state"
state = self.strategy.session_get(name) or self.state_token()
self.strategy.session_set(name, state)
params = self.auth_params(state)
params.update(self.get_scope_argument())
params.update(self.auth_extra_arguments())
return self.AUTHORIZATION_URL + "?" + urlencode(params)
开发者ID:CKFrantz,项目名称:deli-press-upload,代码行数:17,代码来源:soundcloud.py
示例15: unauthorized_token_request
def unauthorized_token_request(self):
"""Return request for unauthorized token (first stage)"""
params = self.request_token_extra_arguments()
params.update(self.get_scope_argument())
key, secret = self.get_key_and_secret()
# decoding='utf-8' produces errors with python-requests on Python3
# since the final URL will be of type bytes
decoding = None if six.PY3 else "utf-8"
state = self.get_or_create_state()
auth = OAuth1(
key,
secret,
callback_uri=self.get_redirect_uri(state),
decoding=decoding,
signature_method=SIGNATURE_HMAC,
signature_type=SIGNATURE_TYPE_QUERY,
)
url = self.REQUEST_TOKEN_URL + "?" + urlencode(params)
url, _, _ = auth.client.sign(url)
return url
开发者ID:meetmeinthebathtub,项目名称:python-social-auth,代码行数:21,代码来源:khanacademy.py
示例16: modify_start_url
def modify_start_url(self, start_url):
"""
Given a SAML redirect URL, parse it and change the ID to
a consistent value, so the request is always identical.
"""
# Parse the SAML Request URL to get the XML being sent to TestShib
url_parts = urlparse(start_url)
query = dict((k, v[0]) for (k, v) in
parse_qs(url_parts.query).iteritems())
xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(
query['SAMLRequest']
)
# Modify the XML:
xml, changed = re.subn(r'ID="[^"]+"', 'ID="TEST_ID"', xml)
self.assertEqual(changed, 1)
# Update the URL to use the modified query string:
query['SAMLRequest'] = OneLogin_Saml2_Utils.deflate_and_base64_encode(
xml
)
url_parts = list(url_parts)
url_parts[4] = urlencode(query)
return urlunparse(url_parts)
开发者ID:2070616d,项目名称:TP3,代码行数:22,代码来源:test_saml.py
注:本文中的social.p3.urlencode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论