partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Grant.delete | Removes itself from the cache
Note: This is required by the oauthlib | flask_oauthlib/contrib/oauth2.py | def delete(self):
"""Removes itself from the cache
Note: This is required by the oauthlib
"""
log.debug(
"Deleting grant %s for client %s" % (self.code, self.client_id)
)
self._cache.delete(self.key)
return None | def delete(self):
"""Removes itself from the cache
Note: This is required by the oauthlib
"""
log.debug(
"Deleting grant %s for client %s" % (self.code, self.client_id)
)
self._cache.delete(self.key)
return None | [
"Removes",
"itself",
"from",
"the",
"cache"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L43-L52 | [
"def",
"delete",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Deleting grant %s for client %s\"",
"%",
"(",
"self",
".",
"code",
",",
"self",
".",
"client_id",
")",
")",
"self",
".",
"_cache",
".",
"delete",
"(",
"self",
".",
"key",
")",
"return... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | BaseBinding.query | Determines which method of getting the query object for use | flask_oauthlib/contrib/oauth2.py | def query(self):
"""Determines which method of getting the query object for use"""
if hasattr(self.model, 'query'):
return self.model.query
else:
return self.session.query(self.model) | def query(self):
"""Determines which method of getting the query object for use"""
if hasattr(self.model, 'query'):
return self.model.query
else:
return self.session.query(self.model) | [
"Determines",
"which",
"method",
"of",
"getting",
"the",
"query",
"object",
"for",
"use"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L203-L208 | [
"def",
"query",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"model",
",",
"'query'",
")",
":",
"return",
"self",
".",
"model",
".",
"query",
"else",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"self",
".",
"model",
")"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | UserBinding.get | Returns the User object
Returns None if the user isn't found or the passwords don't match
:param username: username of the user
:param password: password of the user | flask_oauthlib/contrib/oauth2.py | def get(self, username, password, *args, **kwargs):
"""Returns the User object
Returns None if the user isn't found or the passwords don't match
:param username: username of the user
:param password: password of the user
"""
user = self.query.filter_by(username=username... | def get(self, username, password, *args, **kwargs):
"""Returns the User object
Returns None if the user isn't found or the passwords don't match
:param username: username of the user
:param password: password of the user
"""
user = self.query.filter_by(username=username... | [
"Returns",
"the",
"User",
"object"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L214-L225 | [
"def",
"get",
"(",
"self",
",",
"username",
",",
"password",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"user",
"=",
"self",
".",
"query",
".",
"filter_by",
"(",
"username",
"=",
"username",
")",
".",
"first",
"(",
")",
"if",
"user",
"a... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | TokenBinding.get | returns a Token object with the given access token or refresh token
:param access_token: User's access token
:param refresh_token: User's refresh token | flask_oauthlib/contrib/oauth2.py | def get(self, access_token=None, refresh_token=None):
"""returns a Token object with the given access token or refresh token
:param access_token: User's access token
:param refresh_token: User's refresh token
"""
if access_token:
return self.query.filter_by(access_to... | def get(self, access_token=None, refresh_token=None):
"""returns a Token object with the given access token or refresh token
:param access_token: User's access token
:param refresh_token: User's refresh token
"""
if access_token:
return self.query.filter_by(access_to... | [
"returns",
"a",
"Token",
"object",
"with",
"the",
"given",
"access",
"token",
"or",
"refresh",
"token"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L247-L257 | [
"def",
"get",
"(",
"self",
",",
"access_token",
"=",
"None",
",",
"refresh_token",
"=",
"None",
")",
":",
"if",
"access_token",
":",
"return",
"self",
".",
"query",
".",
"filter_by",
"(",
"access_token",
"=",
"access_token",
")",
".",
"first",
"(",
")",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | TokenBinding.set | Creates a Token object and removes all expired tokens that belong
to the user
:param token: token object
:param request: OAuthlib request object | flask_oauthlib/contrib/oauth2.py | def set(self, token, request, *args, **kwargs):
"""Creates a Token object and removes all expired tokens that belong
to the user
:param token: token object
:param request: OAuthlib request object
"""
if hasattr(request, 'user') and request.user:
user = reques... | def set(self, token, request, *args, **kwargs):
"""Creates a Token object and removes all expired tokens that belong
to the user
:param token: token object
:param request: OAuthlib request object
"""
if hasattr(request, 'user') and request.user:
user = reques... | [
"Creates",
"a",
"Token",
"object",
"and",
"removes",
"all",
"expired",
"tokens",
"that",
"belong",
"to",
"the",
"user"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L259-L292 | [
"def",
"set",
"(",
"self",
",",
"token",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"request",
",",
"'user'",
")",
"and",
"request",
".",
"user",
":",
"user",
"=",
"request",
".",
"user",
"elif",
"s... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | GrantBinding.set | Creates Grant object with the given params
:param client_id: ID of the client
:param code:
:param request: OAuthlib request object | flask_oauthlib/contrib/oauth2.py | def set(self, client_id, code, request, *args, **kwargs):
"""Creates Grant object with the given params
:param client_id: ID of the client
:param code:
:param request: OAuthlib request object
"""
expires = datetime.utcnow() + timedelta(seconds=100)
grant = self.m... | def set(self, client_id, code, request, *args, **kwargs):
"""Creates Grant object with the given params
:param client_id: ID of the client
:param code:
:param request: OAuthlib request object
"""
expires = datetime.utcnow() + timedelta(seconds=100)
grant = self.m... | [
"Creates",
"Grant",
"object",
"with",
"the",
"given",
"params"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L304-L322 | [
"def",
"set",
"(",
"self",
",",
"client_id",
",",
"code",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"expires",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"timedelta",
"(",
"seconds",
"=",
"100",
")",
"grant",
"=",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | GrantBinding.get | Get the Grant object with the given client ID and code
:param client_id: ID of the client
:param code: | flask_oauthlib/contrib/oauth2.py | def get(self, client_id, code):
"""Get the Grant object with the given client ID and code
:param client_id: ID of the client
:param code:
"""
return self.query.filter_by(client_id=client_id, code=code).first() | def get(self, client_id, code):
"""Get the Grant object with the given client ID and code
:param client_id: ID of the client
:param code:
"""
return self.query.filter_by(client_id=client_id, code=code).first() | [
"Get",
"the",
"Grant",
"object",
"with",
"the",
"given",
"client",
"ID",
"and",
"code"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/oauth2.py#L324-L330 | [
"def",
"get",
"(",
"self",
",",
"client_id",
",",
"code",
")",
":",
"return",
"self",
".",
"query",
".",
"filter_by",
"(",
"client_id",
"=",
"client_id",
",",
"code",
"=",
"code",
")",
".",
"first",
"(",
")"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | parse_response | Parse the response returned by :meth:`OAuthRemoteApp.http_request`.
:param resp: response of http_request
:param content: content of the response
:param strict: strict mode for form urlencoded content
:param content_type: assign a content type manually | flask_oauthlib/client.py | def parse_response(resp, content, strict=False, content_type=None):
"""Parse the response returned by :meth:`OAuthRemoteApp.http_request`.
:param resp: response of http_request
:param content: content of the response
:param strict: strict mode for form urlencoded content
:param content_type: assign... | def parse_response(resp, content, strict=False, content_type=None):
"""Parse the response returned by :meth:`OAuthRemoteApp.http_request`.
:param resp: response of http_request
:param content: content of the response
:param strict: strict mode for form urlencoded content
:param content_type: assign... | [
"Parse",
"the",
"response",
"returned",
"by",
":",
"meth",
":",
"OAuthRemoteApp",
".",
"http_request",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L113-L136 | [
"def",
"parse_response",
"(",
"resp",
",",
"content",
",",
"strict",
"=",
"False",
",",
"content_type",
"=",
"None",
")",
":",
"if",
"not",
"content_type",
":",
"content_type",
"=",
"resp",
".",
"headers",
".",
"get",
"(",
"'content-type'",
",",
"'applicat... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | prepare_request | Make request parameters right. | flask_oauthlib/client.py | def prepare_request(uri, headers=None, data=None, method=None):
"""Make request parameters right."""
if headers is None:
headers = {}
if data and not method:
method = 'POST'
elif not method:
method = 'GET'
if method == 'GET' and data:
uri = add_params_to_uri(uri, da... | def prepare_request(uri, headers=None, data=None, method=None):
"""Make request parameters right."""
if headers is None:
headers = {}
if data and not method:
method = 'POST'
elif not method:
method = 'GET'
if method == 'GET' and data:
uri = add_params_to_uri(uri, da... | [
"Make",
"request",
"parameters",
"right",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L139-L153 | [
"def",
"prepare_request",
"(",
"uri",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"method",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"}",
"if",
"data",
"and",
"not",
"method",
":",
"method",
"=... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth.init_app | Init app with Flask instance.
You can also pass the instance of Flask later::
oauth = OAuth()
oauth.init_app(app) | flask_oauthlib/client.py | def init_app(self, app):
"""Init app with Flask instance.
You can also pass the instance of Flask later::
oauth = OAuth()
oauth.init_app(app)
"""
self.app = app
app.extensions = getattr(app, 'extensions', {})
app.extensions[self.state_key] = self | def init_app(self, app):
"""Init app with Flask instance.
You can also pass the instance of Flask later::
oauth = OAuth()
oauth.init_app(app)
"""
self.app = app
app.extensions = getattr(app, 'extensions', {})
app.extensions[self.state_key] = self | [
"Init",
"app",
"with",
"Flask",
"instance",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L57-L67 | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"app",
"=",
"app",
"app",
".",
"extensions",
"=",
"getattr",
"(",
"app",
",",
"'extensions'",
",",
"{",
"}",
")",
"app",
".",
"extensions",
"[",
"self",
".",
"state_key",
"]",
"=",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth.remote_app | Registers a new remote application.
:param name: the name of the remote application
:param register: whether the remote app will be registered
Find more parameters from :class:`OAuthRemoteApp`. | flask_oauthlib/client.py | def remote_app(self, name, register=True, **kwargs):
"""Registers a new remote application.
:param name: the name of the remote application
:param register: whether the remote app will be registered
Find more parameters from :class:`OAuthRemoteApp`.
"""
remote = OAuthRe... | def remote_app(self, name, register=True, **kwargs):
"""Registers a new remote application.
:param name: the name of the remote application
:param register: whether the remote app will be registered
Find more parameters from :class:`OAuthRemoteApp`.
"""
remote = OAuthRe... | [
"Registers",
"a",
"new",
"remote",
"application",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L69-L81 | [
"def",
"remote_app",
"(",
"self",
",",
"name",
",",
"register",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"remote",
"=",
"OAuthRemoteApp",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
"if",
"register",
":",
"assert",
"name",
"not",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuthRemoteApp.request | Sends a request to the remote server with OAuth tokens attached.
:param data: the data to be sent to the server.
:param headers: an optional dictionary of headers.
:param format: the format for the `data`. Can be `urlencoded` for
URL encoded data or `json` for JSON.
... | flask_oauthlib/client.py | def request(self, url, data=None, headers=None, format='urlencoded',
method='GET', content_type=None, token=None):
"""
Sends a request to the remote server with OAuth tokens attached.
:param data: the data to be sent to the server.
:param headers: an optional dictionary ... | def request(self, url, data=None, headers=None, format='urlencoded',
method='GET', content_type=None, token=None):
"""
Sends a request to the remote server with OAuth tokens attached.
:param data: the data to be sent to the server.
:param headers: an optional dictionary ... | [
"Sends",
"a",
"request",
"to",
"the",
"remote",
"server",
"with",
"OAuth",
"tokens",
"attached",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L448-L506 | [
"def",
"request",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"format",
"=",
"'urlencoded'",
",",
"method",
"=",
"'GET'",
",",
"content_type",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"headers",
"=",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuthRemoteApp.authorize | Returns a redirect response to the remote authorization URL with
the signed callback given.
:param callback: a redirect url for the callback
:param state: an optional value to embed in the OAuth request.
Use this if you want to pass around application
... | flask_oauthlib/client.py | def authorize(self, callback=None, state=None, **kwargs):
"""
Returns a redirect response to the remote authorization URL with
the signed callback given.
:param callback: a redirect url for the callback
:param state: an optional value to embed in the OAuth request.
... | def authorize(self, callback=None, state=None, **kwargs):
"""
Returns a redirect response to the remote authorization URL with
the signed callback given.
:param callback: a redirect url for the callback
:param state: an optional value to embed in the OAuth request.
... | [
"Returns",
"a",
"redirect",
"response",
"to",
"the",
"remote",
"authorization",
"URL",
"with",
"the",
"signed",
"callback",
"given",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L508-L562 | [
"def",
"authorize",
"(",
"self",
",",
"callback",
"=",
"None",
",",
"state",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"dict",
"(",
"self",
".",
"request_token_params",
")",
"or",
"{",
"}",
"params",
".",
"update",
"(",
"*",
"*... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuthRemoteApp.handle_oauth1_response | Handles an oauth1 authorization response. | flask_oauthlib/client.py | def handle_oauth1_response(self, args):
"""Handles an oauth1 authorization response."""
client = self.make_client()
client.verifier = args.get('oauth_verifier')
tup = session.get('%s_oauthtok' % self.name)
if not tup:
raise OAuthException(
'Token not f... | def handle_oauth1_response(self, args):
"""Handles an oauth1 authorization response."""
client = self.make_client()
client.verifier = args.get('oauth_verifier')
tup = session.get('%s_oauthtok' % self.name)
if not tup:
raise OAuthException(
'Token not f... | [
"Handles",
"an",
"oauth1",
"authorization",
"response",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L621-L650 | [
"def",
"handle_oauth1_response",
"(",
"self",
",",
"args",
")",
":",
"client",
"=",
"self",
".",
"make_client",
"(",
")",
"client",
".",
"verifier",
"=",
"args",
".",
"get",
"(",
"'oauth_verifier'",
")",
"tup",
"=",
"session",
".",
"get",
"(",
"'%s_oauth... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuthRemoteApp.handle_oauth2_response | Handles an oauth2 authorization response. | flask_oauthlib/client.py | def handle_oauth2_response(self, args):
"""Handles an oauth2 authorization response."""
client = self.make_client()
remote_args = {
'code': args.get('code'),
'client_secret': self.consumer_secret,
'redirect_uri': session.get('%s_oauthredir' % self.name)
... | def handle_oauth2_response(self, args):
"""Handles an oauth2 authorization response."""
client = self.make_client()
remote_args = {
'code': args.get('code'),
'client_secret': self.consumer_secret,
'redirect_uri': session.get('%s_oauthredir' % self.name)
... | [
"Handles",
"an",
"oauth2",
"authorization",
"response",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L652-L694 | [
"def",
"handle_oauth2_response",
"(",
"self",
",",
"args",
")",
":",
"client",
"=",
"self",
".",
"make_client",
"(",
")",
"remote_args",
"=",
"{",
"'code'",
":",
"args",
".",
"get",
"(",
"'code'",
")",
",",
"'client_secret'",
":",
"self",
".",
"consumer_... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuthRemoteApp.authorized_response | Handles authorization response smartly. | flask_oauthlib/client.py | def authorized_response(self, args=None):
"""Handles authorization response smartly."""
if args is None:
args = request.args
if 'oauth_verifier' in args:
data = self.handle_oauth1_response(args)
elif 'code' in args:
data = self.handle_oauth2_response(a... | def authorized_response(self, args=None):
"""Handles authorization response smartly."""
if args is None:
args = request.args
if 'oauth_verifier' in args:
data = self.handle_oauth1_response(args)
elif 'code' in args:
data = self.handle_oauth2_response(a... | [
"Handles",
"authorization",
"response",
"smartly",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L700-L714 | [
"def",
"authorized_response",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"request",
".",
"args",
"if",
"'oauth_verifier'",
"in",
"args",
":",
"data",
"=",
"self",
".",
"handle_oauth1_response",
"(",
"ar... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuthRemoteApp.authorized_handler | Handles an OAuth callback.
.. versionchanged:: 0.7
@authorized_handler is deprecated in favor of authorized_response. | flask_oauthlib/client.py | def authorized_handler(self, f):
"""Handles an OAuth callback.
.. versionchanged:: 0.7
@authorized_handler is deprecated in favor of authorized_response.
"""
@wraps(f)
def decorated(*args, **kwargs):
log.warn(
'@authorized_handler is deprec... | def authorized_handler(self, f):
"""Handles an OAuth callback.
.. versionchanged:: 0.7
@authorized_handler is deprecated in favor of authorized_response.
"""
@wraps(f)
def decorated(*args, **kwargs):
log.warn(
'@authorized_handler is deprec... | [
"Handles",
"an",
"OAuth",
"callback",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/client.py#L716-L730 | [
"def",
"authorized_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"warn",
"(",
"'@authorized_handler is deprecated in favor of '",
"'authorized_resp... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | _hash_token | Creates a hashable object for given token then we could use it as a
dictionary key. | flask_oauthlib/contrib/client/application.py | def _hash_token(application, token):
"""Creates a hashable object for given token then we could use it as a
dictionary key.
"""
if isinstance(token, dict):
hashed_token = tuple(sorted(token.items()))
elif isinstance(token, tuple):
hashed_token = token
else:
raise TypeErro... | def _hash_token(application, token):
"""Creates a hashable object for given token then we could use it as a
dictionary key.
"""
if isinstance(token, dict):
hashed_token = tuple(sorted(token.items()))
elif isinstance(token, tuple):
hashed_token = token
else:
raise TypeErro... | [
"Creates",
"a",
"hashable",
"object",
"for",
"given",
"token",
"then",
"we",
"could",
"use",
"it",
"as",
"a",
"dictionary",
"key",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/application.py#L328-L339 | [
"def",
"_hash_token",
"(",
"application",
",",
"token",
")",
":",
"if",
"isinstance",
"(",
"token",
",",
"dict",
")",
":",
"hashed_token",
"=",
"tuple",
"(",
"sorted",
"(",
"token",
".",
"items",
"(",
")",
")",
")",
"elif",
"isinstance",
"(",
"token",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | BaseApplication.client | The lazy-created OAuth session with the return value of
:meth:`tokengetter`.
:returns: The OAuth session instance or ``None`` while token missing. | flask_oauthlib/contrib/client/application.py | def client(self):
"""The lazy-created OAuth session with the return value of
:meth:`tokengetter`.
:returns: The OAuth session instance or ``None`` while token missing.
"""
token = self.obtain_token()
if token is None:
raise AccessTokenNotFound
return ... | def client(self):
"""The lazy-created OAuth session with the return value of
:meth:`tokengetter`.
:returns: The OAuth session instance or ``None`` while token missing.
"""
token = self.obtain_token()
if token is None:
raise AccessTokenNotFound
return ... | [
"The",
"lazy",
"-",
"created",
"OAuth",
"session",
"with",
"the",
"return",
"value",
"of",
":",
"meth",
":",
"tokengetter",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/application.py#L77-L86 | [
"def",
"client",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"obtain_token",
"(",
")",
"if",
"token",
"is",
"None",
":",
"raise",
"AccessTokenNotFound",
"return",
"self",
".",
"_make_client_with_token",
"(",
"token",
")"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | BaseApplication._make_client_with_token | Uses cached client or create new one with specific token. | flask_oauthlib/contrib/client/application.py | def _make_client_with_token(self, token):
"""Uses cached client or create new one with specific token."""
cached_clients = getattr(self, 'clients', None)
hashed_token = _hash_token(self, token)
if cached_clients and hashed_token in cached_clients:
return cached_clients[hashe... | def _make_client_with_token(self, token):
"""Uses cached client or create new one with specific token."""
cached_clients = getattr(self, 'clients', None)
hashed_token = _hash_token(self, token)
if cached_clients and hashed_token in cached_clients:
return cached_clients[hashe... | [
"Uses",
"cached",
"client",
"or",
"create",
"new",
"one",
"with",
"specific",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/application.py#L88-L100 | [
"def",
"_make_client_with_token",
"(",
"self",
",",
"token",
")",
":",
"cached_clients",
"=",
"getattr",
"(",
"self",
",",
"'clients'",
",",
"None",
")",
"hashed_token",
"=",
"_hash_token",
"(",
"self",
",",
"token",
")",
"if",
"cached_clients",
"and",
"hash... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1Application.make_client | Creates a client with specific access token pair.
:param token: a tuple of access token pair ``(token, token_secret)``
or a dictionary of access token response.
:returns: a :class:`requests_oauthlib.oauth1_session.OAuth1Session`
object. | flask_oauthlib/contrib/client/application.py | def make_client(self, token):
"""Creates a client with specific access token pair.
:param token: a tuple of access token pair ``(token, token_secret)``
or a dictionary of access token response.
:returns: a :class:`requests_oauthlib.oauth1_session.OAuth1Session`
... | def make_client(self, token):
"""Creates a client with specific access token pair.
:param token: a tuple of access token pair ``(token, token_secret)``
or a dictionary of access token response.
:returns: a :class:`requests_oauthlib.oauth1_session.OAuth1Session`
... | [
"Creates",
"a",
"client",
"with",
"specific",
"access",
"token",
"pair",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/application.py#L160-L175 | [
"def",
"make_client",
"(",
"self",
",",
"token",
")",
":",
"if",
"isinstance",
"(",
"token",
",",
"dict",
")",
":",
"access_token",
"=",
"token",
"[",
"'oauth_token'",
"]",
"access_token_secret",
"=",
"token",
"[",
"'oauth_token_secret'",
"]",
"else",
":",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Application.insecure_transport | Creates a context to enable the oauthlib environment variable in
order to debug with insecure transport. | flask_oauthlib/contrib/client/application.py | def insecure_transport(self):
"""Creates a context to enable the oauthlib environment variable in
order to debug with insecure transport.
"""
origin = os.environ.get('OAUTHLIB_INSECURE_TRANSPORT')
if current_app.debug or current_app.testing:
try:
os.en... | def insecure_transport(self):
"""Creates a context to enable the oauthlib environment variable in
order to debug with insecure transport.
"""
origin = os.environ.get('OAUTHLIB_INSECURE_TRANSPORT')
if current_app.debug or current_app.testing:
try:
os.en... | [
"Creates",
"a",
"context",
"to",
"enable",
"the",
"oauthlib",
"environment",
"variable",
"in",
"order",
"to",
"debug",
"with",
"insecure",
"transport",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/application.py#L304-L325 | [
"def",
"insecure_transport",
"(",
"self",
")",
":",
"origin",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'OAUTHLIB_INSECURE_TRANSPORT'",
")",
"if",
"current_app",
".",
"debug",
"or",
"current_app",
".",
"testing",
":",
"try",
":",
"os",
".",
"environ",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1Provider.server | All in one endpoints. This property is created automaticly
if you have implemented all the getters and setters. | flask_oauthlib/provider/oauth1.py | def server(self):
"""
All in one endpoints. This property is created automaticly
if you have implemented all the getters and setters.
"""
if hasattr(self, '_validator'):
return Server(self._validator)
if hasattr(self, '_clientgetter') and \
hasattr... | def server(self):
"""
All in one endpoints. This property is created automaticly
if you have implemented all the getters and setters.
"""
if hasattr(self, '_validator'):
return Server(self._validator)
if hasattr(self, '_clientgetter') and \
hasattr... | [
"All",
"in",
"one",
"endpoints",
".",
"This",
"property",
"is",
"created",
"automaticly",
"if",
"you",
"have",
"implemented",
"all",
"the",
"getters",
"and",
"setters",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L93-L133 | [
"def",
"server",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_validator'",
")",
":",
"return",
"Server",
"(",
"self",
".",
"_validator",
")",
"if",
"hasattr",
"(",
"self",
",",
"'_clientgetter'",
")",
"and",
"hasattr",
"(",
"self",
",",... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1Provider.authorize_handler | Authorization handler decorator.
This decorator will sort the parameters and headers out, and
pre validate everything::
@app.route('/oauth/authorize', methods=['GET', 'POST'])
@oauth.authorize_handler
def authorize(*args, **kwargs):
if request.method... | flask_oauthlib/provider/oauth1.py | def authorize_handler(self, f):
"""Authorization handler decorator.
This decorator will sort the parameters and headers out, and
pre validate everything::
@app.route('/oauth/authorize', methods=['GET', 'POST'])
@oauth.authorize_handler
def authorize(*args, *... | def authorize_handler(self, f):
"""Authorization handler decorator.
This decorator will sort the parameters and headers out, and
pre validate everything::
@app.route('/oauth/authorize', methods=['GET', 'POST'])
@oauth.authorize_handler
def authorize(*args, *... | [
"Authorization",
"handler",
"decorator",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L371-L411 | [
"def",
"authorize_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"if",
"not",
"f",
"(",
"*",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1Provider.confirm_authorization_request | When consumer confirm the authrozation. | flask_oauthlib/provider/oauth1.py | def confirm_authorization_request(self):
"""When consumer confirm the authrozation."""
server = self.server
uri, http_method, body, headers = extract_params()
try:
realms, credentials = server.get_realms_and_credentials(
uri, http_method=http_method, body=bod... | def confirm_authorization_request(self):
"""When consumer confirm the authrozation."""
server = self.server
uri, http_method, body, headers = extract_params()
try:
realms, credentials = server.get_realms_and_credentials(
uri, http_method=http_method, body=bod... | [
"When",
"consumer",
"confirm",
"the",
"authrozation",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L413-L430 | [
"def",
"confirm_authorization_request",
"(",
"self",
")",
":",
"server",
"=",
"self",
".",
"server",
"uri",
",",
"http_method",
",",
"body",
",",
"headers",
"=",
"extract_params",
"(",
")",
"try",
":",
"realms",
",",
"credentials",
"=",
"server",
".",
"get... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1Provider.request_token_handler | Request token handler decorator.
The decorated function should return an dictionary or None as
the extra credentials for creating the token response.
If you don't need to add any extra credentials, it could be as
simple as::
@app.route('/oauth/request_token')
@... | flask_oauthlib/provider/oauth1.py | def request_token_handler(self, f):
"""Request token handler decorator.
The decorated function should return an dictionary or None as
the extra credentials for creating the token response.
If you don't need to add any extra credentials, it could be as
simple as::
@... | def request_token_handler(self, f):
"""Request token handler decorator.
The decorated function should return an dictionary or None as
the extra credentials for creating the token response.
If you don't need to add any extra credentials, it could be as
simple as::
@... | [
"Request",
"token",
"handler",
"decorator",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L432-L457 | [
"def",
"request_token_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"server",
"=",
"self",
".",
"server",
"uri",
",",
"http_method",
",",
"body",
","... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1Provider.require_oauth | Protect resource with specified scopes. | flask_oauthlib/provider/oauth1.py | def require_oauth(self, *realms, **kwargs):
"""Protect resource with specified scopes."""
def wrapper(f):
@wraps(f)
def decorated(*args, **kwargs):
for func in self._before_request_funcs:
func()
if hasattr(request, 'oauth') and... | def require_oauth(self, *realms, **kwargs):
"""Protect resource with specified scopes."""
def wrapper(f):
@wraps(f)
def decorated(*args, **kwargs):
for func in self._before_request_funcs:
func()
if hasattr(request, 'oauth') and... | [
"Protect",
"resource",
"with",
"specified",
"scopes",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L486-L518 | [
"def",
"require_oauth",
"(",
"self",
",",
"*",
"realms",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_client_secret | Get client secret.
The client object must has ``client_secret`` attribute. | flask_oauthlib/provider/oauth1.py | def get_client_secret(self, client_key, request):
"""Get client secret.
The client object must has ``client_secret`` attribute.
"""
log.debug('Get client secret of %r', client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
... | def get_client_secret(self, client_key, request):
"""Get client secret.
The client object must has ``client_secret`` attribute.
"""
log.debug('Get client secret of %r', client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
... | [
"Get",
"client",
"secret",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L632-L642 | [
"def",
"get_client_secret",
"(",
"self",
",",
"client_key",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Get client secret of %r'",
",",
"client_key",
")",
"if",
"not",
"request",
".",
"client",
":",
"request",
".",
"client",
"=",
"self",
".",
"_c... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_request_token_secret | Get request token secret.
The request token object should a ``secret`` attribute. | flask_oauthlib/provider/oauth1.py | def get_request_token_secret(self, client_key, token, request):
"""Get request token secret.
The request token object should a ``secret`` attribute.
"""
log.debug('Get request token secret of %r for %r',
token, client_key)
tok = request.request_token or self._g... | def get_request_token_secret(self, client_key, token, request):
"""Get request token secret.
The request token object should a ``secret`` attribute.
"""
log.debug('Get request token secret of %r for %r',
token, client_key)
tok = request.request_token or self._g... | [
"Get",
"request",
"token",
"secret",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L644-L655 | [
"def",
"get_request_token_secret",
"(",
"self",
",",
"client_key",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Get request token secret of %r for %r'",
",",
"token",
",",
"client_key",
")",
"tok",
"=",
"request",
".",
"request_token",
"or... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_access_token_secret | Get access token secret.
The access token object should a ``secret`` attribute. | flask_oauthlib/provider/oauth1.py | def get_access_token_secret(self, client_key, token, request):
"""Get access token secret.
The access token object should a ``secret`` attribute.
"""
log.debug('Get access token secret of %r for %r',
token, client_key)
tok = request.access_token or self._tokeng... | def get_access_token_secret(self, client_key, token, request):
"""Get access token secret.
The access token object should a ``secret`` attribute.
"""
log.debug('Get access token secret of %r for %r',
token, client_key)
tok = request.access_token or self._tokeng... | [
"Get",
"access",
"token",
"secret",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L657-L671 | [
"def",
"get_access_token_secret",
"(",
"self",
",",
"client_key",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Get access token secret of %r for %r'",
",",
"token",
",",
"client_key",
")",
"tok",
"=",
"request",
".",
"access_token",
"or",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_default_realms | Default realms of the client. | flask_oauthlib/provider/oauth1.py | def get_default_realms(self, client_key, request):
"""Default realms of the client."""
log.debug('Get realms for %r', client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
client = request.client
if hasattr(client, 'default_re... | def get_default_realms(self, client_key, request):
"""Default realms of the client."""
log.debug('Get realms for %r', client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
client = request.client
if hasattr(client, 'default_re... | [
"Default",
"realms",
"of",
"the",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L673-L683 | [
"def",
"get_default_realms",
"(",
"self",
",",
"client_key",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Get realms for %r'",
",",
"client_key",
")",
"if",
"not",
"request",
".",
"client",
":",
"request",
".",
"client",
"=",
"self",
".",
"_client... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_realms | Realms for this request token. | flask_oauthlib/provider/oauth1.py | def get_realms(self, token, request):
"""Realms for this request token."""
log.debug('Get realms of %r', token)
tok = request.request_token or self._grantgetter(token=token)
if not tok:
return []
request.request_token = tok
if hasattr(tok, 'realms'):
... | def get_realms(self, token, request):
"""Realms for this request token."""
log.debug('Get realms of %r', token)
tok = request.request_token or self._grantgetter(token=token)
if not tok:
return []
request.request_token = tok
if hasattr(tok, 'realms'):
... | [
"Realms",
"for",
"this",
"request",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L685-L694 | [
"def",
"get_realms",
"(",
"self",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Get realms of %r'",
",",
"token",
")",
"tok",
"=",
"request",
".",
"request_token",
"or",
"self",
".",
"_grantgetter",
"(",
"token",
"=",
"token",
")",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_redirect_uri | Redirect uri for this request token. | flask_oauthlib/provider/oauth1.py | def get_redirect_uri(self, token, request):
"""Redirect uri for this request token."""
log.debug('Get redirect uri of %r', token)
tok = request.request_token or self._grantgetter(token=token)
return tok.redirect_uri | def get_redirect_uri(self, token, request):
"""Redirect uri for this request token."""
log.debug('Get redirect uri of %r', token)
tok = request.request_token or self._grantgetter(token=token)
return tok.redirect_uri | [
"Redirect",
"uri",
"for",
"this",
"request",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L696-L700 | [
"def",
"get_redirect_uri",
"(",
"self",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Get redirect uri of %r'",
",",
"token",
")",
"tok",
"=",
"request",
".",
"request_token",
"or",
"self",
".",
"_grantgetter",
"(",
"token",
"=",
"tok... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.get_rsa_key | Retrieves a previously stored client provided RSA key. | flask_oauthlib/provider/oauth1.py | def get_rsa_key(self, client_key, request):
"""Retrieves a previously stored client provided RSA key."""
if not request.client:
request.client = self._clientgetter(client_key=client_key)
if hasattr(request.client, 'rsa_key'):
return request.client.rsa_key
return N... | def get_rsa_key(self, client_key, request):
"""Retrieves a previously stored client provided RSA key."""
if not request.client:
request.client = self._clientgetter(client_key=client_key)
if hasattr(request.client, 'rsa_key'):
return request.client.rsa_key
return N... | [
"Retrieves",
"a",
"previously",
"stored",
"client",
"provided",
"RSA",
"key",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L702-L708 | [
"def",
"get_rsa_key",
"(",
"self",
",",
"client_key",
",",
"request",
")",
":",
"if",
"not",
"request",
".",
"client",
":",
"request",
".",
"client",
"=",
"self",
".",
"_clientgetter",
"(",
"client_key",
"=",
"client_key",
")",
"if",
"hasattr",
"(",
"req... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_client_key | Validates that supplied client key. | flask_oauthlib/provider/oauth1.py | def validate_client_key(self, client_key, request):
"""Validates that supplied client key."""
log.debug('Validate client key for %r', client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
if request.client:
return True
... | def validate_client_key(self, client_key, request):
"""Validates that supplied client key."""
log.debug('Validate client key for %r', client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
if request.client:
return True
... | [
"Validates",
"that",
"supplied",
"client",
"key",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L714-L721 | [
"def",
"validate_client_key",
"(",
"self",
",",
"client_key",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Validate client key for %r'",
",",
"client_key",
")",
"if",
"not",
"request",
".",
"client",
":",
"request",
".",
"client",
"=",
"self",
".",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_request_token | Validates request token is available for client. | flask_oauthlib/provider/oauth1.py | def validate_request_token(self, client_key, token, request):
"""Validates request token is available for client."""
log.debug('Validate request token %r for %r',
token, client_key)
tok = request.request_token or self._grantgetter(token=token)
if tok and tok.client_key ... | def validate_request_token(self, client_key, token, request):
"""Validates request token is available for client."""
log.debug('Validate request token %r for %r',
token, client_key)
tok = request.request_token or self._grantgetter(token=token)
if tok and tok.client_key ... | [
"Validates",
"request",
"token",
"is",
"available",
"for",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L723-L731 | [
"def",
"validate_request_token",
"(",
"self",
",",
"client_key",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Validate request token %r for %r'",
",",
"token",
",",
"client_key",
")",
"tok",
"=",
"request",
".",
"request_token",
"or",
"s... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_access_token | Validates access token is available for client. | flask_oauthlib/provider/oauth1.py | def validate_access_token(self, client_key, token, request):
"""Validates access token is available for client."""
log.debug('Validate access token %r for %r',
token, client_key)
tok = request.access_token or self._tokengetter(
client_key=client_key,
tok... | def validate_access_token(self, client_key, token, request):
"""Validates access token is available for client."""
log.debug('Validate access token %r for %r',
token, client_key)
tok = request.access_token or self._tokengetter(
client_key=client_key,
tok... | [
"Validates",
"access",
"token",
"is",
"available",
"for",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L733-L744 | [
"def",
"validate_access_token",
"(",
"self",
",",
"client_key",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Validate access token %r for %r'",
",",
"token",
",",
"client_key",
")",
"tok",
"=",
"request",
".",
"access_token",
"or",
"self... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_timestamp_and_nonce | Validate the timestamp and nonce is used or not. | flask_oauthlib/provider/oauth1.py | def validate_timestamp_and_nonce(self, client_key, timestamp, nonce,
request, request_token=None,
access_token=None):
"""Validate the timestamp and nonce is used or not."""
log.debug('Validate timestamp and nonce %r', client_key)
... | def validate_timestamp_and_nonce(self, client_key, timestamp, nonce,
request, request_token=None,
access_token=None):
"""Validate the timestamp and nonce is used or not."""
log.debug('Validate timestamp and nonce %r', client_key)
... | [
"Validate",
"the",
"timestamp",
"and",
"nonce",
"is",
"used",
"or",
"not",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L746-L763 | [
"def",
"validate_timestamp_and_nonce",
"(",
"self",
",",
"client_key",
",",
"timestamp",
",",
"nonce",
",",
"request",
",",
"request_token",
"=",
"None",
",",
"access_token",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'Validate timestamp and nonce %r'",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_redirect_uri | Validate if the redirect_uri is allowed by the client. | flask_oauthlib/provider/oauth1.py | def validate_redirect_uri(self, client_key, redirect_uri, request):
"""Validate if the redirect_uri is allowed by the client."""
log.debug('Validate redirect_uri %r for %r', redirect_uri, client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
... | def validate_redirect_uri(self, client_key, redirect_uri, request):
"""Validate if the redirect_uri is allowed by the client."""
log.debug('Validate redirect_uri %r for %r', redirect_uri, client_key)
if not request.client:
request.client = self._clientgetter(client_key=client_key)
... | [
"Validate",
"if",
"the",
"redirect_uri",
"is",
"allowed",
"by",
"the",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L765-L775 | [
"def",
"validate_redirect_uri",
"(",
"self",
",",
"client_key",
",",
"redirect_uri",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Validate redirect_uri %r for %r'",
",",
"redirect_uri",
",",
"client_key",
")",
"if",
"not",
"request",
".",
"client",
":",... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_realms | Check if the token has permission on those realms. | flask_oauthlib/provider/oauth1.py | def validate_realms(self, client_key, token, request, uri=None,
realms=None):
"""Check if the token has permission on those realms."""
log.debug('Validate realms %r for %r', realms, client_key)
if request.access_token:
tok = request.access_token
else:
... | def validate_realms(self, client_key, token, request, uri=None,
realms=None):
"""Check if the token has permission on those realms."""
log.debug('Validate realms %r for %r', realms, client_key)
if request.access_token:
tok = request.access_token
else:
... | [
"Check",
"if",
"the",
"token",
"has",
"permission",
"on",
"those",
"realms",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L792-L803 | [
"def",
"validate_realms",
"(",
"self",
",",
"client_key",
",",
"token",
",",
"request",
",",
"uri",
"=",
"None",
",",
"realms",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'Validate realms %r for %r'",
",",
"realms",
",",
"client_key",
")",
"if",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.validate_verifier | Validate verifier exists. | flask_oauthlib/provider/oauth1.py | def validate_verifier(self, client_key, token, verifier, request):
"""Validate verifier exists."""
log.debug('Validate verifier %r for %r', verifier, client_key)
data = self._verifiergetter(verifier=verifier, token=token)
if not data:
return False
if not hasattr(data,... | def validate_verifier(self, client_key, token, verifier, request):
"""Validate verifier exists."""
log.debug('Validate verifier %r for %r', verifier, client_key)
data = self._verifiergetter(verifier=verifier, token=token)
if not data:
return False
if not hasattr(data,... | [
"Validate",
"verifier",
"exists",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L805-L817 | [
"def",
"validate_verifier",
"(",
"self",
",",
"client_key",
",",
"token",
",",
"verifier",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Validate verifier %r for %r'",
",",
"verifier",
",",
"client_key",
")",
"data",
"=",
"self",
".",
"_verifiergetter"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.verify_request_token | Verify if the request token is existed. | flask_oauthlib/provider/oauth1.py | def verify_request_token(self, token, request):
"""Verify if the request token is existed."""
log.debug('Verify request token %r', token)
tok = request.request_token or self._grantgetter(token=token)
if tok:
request.request_token = tok
return True
return F... | def verify_request_token(self, token, request):
"""Verify if the request token is existed."""
log.debug('Verify request token %r', token)
tok = request.request_token or self._grantgetter(token=token)
if tok:
request.request_token = tok
return True
return F... | [
"Verify",
"if",
"the",
"request",
"token",
"is",
"existed",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L819-L826 | [
"def",
"verify_request_token",
"(",
"self",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Verify request token %r'",
",",
"token",
")",
"tok",
"=",
"request",
".",
"request_token",
"or",
"self",
".",
"_grantgetter",
"(",
"token",
"=",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.verify_realms | Verify if the realms match the requested realms. | flask_oauthlib/provider/oauth1.py | def verify_realms(self, token, realms, request):
"""Verify if the realms match the requested realms."""
log.debug('Verify realms %r', realms)
tok = request.request_token or self._grantgetter(token=token)
if not tok:
return False
request.request_token = tok
if... | def verify_realms(self, token, realms, request):
"""Verify if the realms match the requested realms."""
log.debug('Verify realms %r', realms)
tok = request.request_token or self._grantgetter(token=token)
if not tok:
return False
request.request_token = tok
if... | [
"Verify",
"if",
"the",
"realms",
"match",
"the",
"requested",
"realms",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L828-L839 | [
"def",
"verify_realms",
"(",
"self",
",",
"token",
",",
"realms",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Verify realms %r'",
",",
"realms",
")",
"tok",
"=",
"request",
".",
"request_token",
"or",
"self",
".",
"_grantgetter",
"(",
"token",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.save_access_token | Save access token to database.
A tokensetter is required, which accepts a token and request
parameters::
def tokensetter(token, request):
access_token = Token(
client=request.client,
user=request.user,
token=token[... | flask_oauthlib/provider/oauth1.py | def save_access_token(self, token, request):
"""Save access token to database.
A tokensetter is required, which accepts a token and request
parameters::
def tokensetter(token, request):
access_token = Token(
client=request.client,
... | def save_access_token(self, token, request):
"""Save access token to database.
A tokensetter is required, which accepts a token and request
parameters::
def tokensetter(token, request):
access_token = Token(
client=request.client,
... | [
"Save",
"access",
"token",
"to",
"database",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L841-L858 | [
"def",
"save_access_token",
"(",
"self",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Save access token %r'",
",",
"token",
")",
"self",
".",
"_tokensetter",
"(",
"token",
",",
"request",
")"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.save_request_token | Save request token to database.
A grantsetter is required, which accepts a token and request
parameters::
def grantsetter(token, request):
grant = Grant(
token=token['oauth_token'],
secret=token['oauth_token_secret'],
... | flask_oauthlib/provider/oauth1.py | def save_request_token(self, token, request):
"""Save request token to database.
A grantsetter is required, which accepts a token and request
parameters::
def grantsetter(token, request):
grant = Grant(
token=token['oauth_token'],
... | def save_request_token(self, token, request):
"""Save request token to database.
A grantsetter is required, which accepts a token and request
parameters::
def grantsetter(token, request):
grant = Grant(
token=token['oauth_token'],
... | [
"Save",
"request",
"token",
"to",
"database",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L860-L877 | [
"def",
"save_request_token",
"(",
"self",
",",
"token",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Save request token %r'",
",",
"token",
")",
"self",
".",
"_grantsetter",
"(",
"token",
",",
"request",
")"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth1RequestValidator.save_verifier | Save verifier to database.
A verifiersetter is required. It would be better to combine request
token and verifier together::
def verifiersetter(token, verifier, request):
tok = Grant.query.filter_by(token=token).first()
tok.verifier = verifier['oauth_verifie... | flask_oauthlib/provider/oauth1.py | def save_verifier(self, token, verifier, request):
"""Save verifier to database.
A verifiersetter is required. It would be better to combine request
token and verifier together::
def verifiersetter(token, verifier, request):
tok = Grant.query.filter_by(token=token).... | def save_verifier(self, token, verifier, request):
"""Save verifier to database.
A verifiersetter is required. It would be better to combine request
token and verifier together::
def verifiersetter(token, verifier, request):
tok = Grant.query.filter_by(token=token).... | [
"Save",
"verifier",
"to",
"database",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L879-L899 | [
"def",
"save_verifier",
"(",
"self",
",",
"token",
",",
"verifier",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Save verifier %r for %r'",
",",
"verifier",
",",
"token",
")",
"self",
".",
"_verifiersetter",
"(",
"token",
"=",
"token",
",",
"verif... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.error_uri | The error page URI.
When something turns error, it will redirect to this error page.
You can configure the error page URI with Flask config::
OAUTH2_PROVIDER_ERROR_URI = '/error'
You can also define the error page by a named endpoint::
OAUTH2_PROVIDER_ERROR_ENDPOINT =... | flask_oauthlib/provider/oauth2.py | def error_uri(self):
"""The error page URI.
When something turns error, it will redirect to this error page.
You can configure the error page URI with Flask config::
OAUTH2_PROVIDER_ERROR_URI = '/error'
You can also define the error page by a named endpoint::
... | def error_uri(self):
"""The error page URI.
When something turns error, it will redirect to this error page.
You can configure the error page URI with Flask config::
OAUTH2_PROVIDER_ERROR_URI = '/error'
You can also define the error page by a named endpoint::
... | [
"The",
"error",
"page",
"URI",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L98-L116 | [
"def",
"error_uri",
"(",
"self",
")",
":",
"error_uri",
"=",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'OAUTH2_PROVIDER_ERROR_URI'",
")",
"if",
"error_uri",
":",
"return",
"error_uri",
"error_endpoint",
"=",
"self",
".",
"app",
".",
"config",
".... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.server | All in one endpoints. This property is created automaticly
if you have implemented all the getters and setters.
However, if you are not satisfied with the getter and setter,
you can create a validator with :class:`OAuth2RequestValidator`::
class MyValidator(OAuth2RequestValidator):... | flask_oauthlib/provider/oauth2.py | def server(self):
"""
All in one endpoints. This property is created automaticly
if you have implemented all the getters and setters.
However, if you are not satisfied with the getter and setter,
you can create a validator with :class:`OAuth2RequestValidator`::
clas... | def server(self):
"""
All in one endpoints. This property is created automaticly
if you have implemented all the getters and setters.
However, if you are not satisfied with the getter and setter,
you can create a validator with :class:`OAuth2RequestValidator`::
clas... | [
"All",
"in",
"one",
"endpoints",
".",
"This",
"property",
"is",
"created",
"automaticly",
"if",
"you",
"have",
"implemented",
"all",
"the",
"getters",
"and",
"setters",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L119-L185 | [
"def",
"server",
"(",
"self",
")",
":",
"expires_in",
"=",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'OAUTH2_PROVIDER_TOKEN_EXPIRES_IN'",
")",
"token_generator",
"=",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'OAUTH2_PROVIDER_TOKEN_GENERA... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.authorize_handler | Authorization handler decorator.
This decorator will sort the parameters and headers out, and
pre validate everything::
@app.route('/oauth/authorize', methods=['GET', 'POST'])
@oauth.authorize_handler
def authorize(*args, **kwargs):
if request.method... | flask_oauthlib/provider/oauth2.py | def authorize_handler(self, f):
"""Authorization handler decorator.
This decorator will sort the parameters and headers out, and
pre validate everything::
@app.route('/oauth/authorize', methods=['GET', 'POST'])
@oauth.authorize_handler
def authorize(*args, *... | def authorize_handler(self, f):
"""Authorization handler decorator.
This decorator will sort the parameters and headers out, and
pre validate everything::
@app.route('/oauth/authorize', methods=['GET', 'POST'])
@oauth.authorize_handler
def authorize(*args, *... | [
"Authorization",
"handler",
"decorator",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L400-L477 | [
"def",
"authorize_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# raise if server not implemented",
"server",
"=",
"self",
".",
"server",
"uri",
",",
"h... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.confirm_authorization_request | When consumer confirm the authorization. | flask_oauthlib/provider/oauth2.py | def confirm_authorization_request(self):
"""When consumer confirm the authorization."""
server = self.server
scope = request.values.get('scope') or ''
scopes = scope.split()
credentials = dict(
client_id=request.values.get('client_id'),
redirect_uri=reques... | def confirm_authorization_request(self):
"""When consumer confirm the authorization."""
server = self.server
scope = request.values.get('scope') or ''
scopes = scope.split()
credentials = dict(
client_id=request.values.get('client_id'),
redirect_uri=reques... | [
"When",
"consumer",
"confirm",
"the",
"authorization",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L479-L515 | [
"def",
"confirm_authorization_request",
"(",
"self",
")",
":",
"server",
"=",
"self",
".",
"server",
"scope",
"=",
"request",
".",
"values",
".",
"get",
"(",
"'scope'",
")",
"or",
"''",
"scopes",
"=",
"scope",
".",
"split",
"(",
")",
"credentials",
"=",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.verify_request | Verify current request, get the oauth data.
If you can't use the ``require_oauth`` decorator, you can fetch
the data in your request body::
def your_handler():
valid, req = oauth.verify_request(['email'])
if valid:
return jsonify(user=req... | flask_oauthlib/provider/oauth2.py | def verify_request(self, scopes):
"""Verify current request, get the oauth data.
If you can't use the ``require_oauth`` decorator, you can fetch
the data in your request body::
def your_handler():
valid, req = oauth.verify_request(['email'])
if valid... | def verify_request(self, scopes):
"""Verify current request, get the oauth data.
If you can't use the ``require_oauth`` decorator, you can fetch
the data in your request body::
def your_handler():
valid, req = oauth.verify_request(['email'])
if valid... | [
"Verify",
"current",
"request",
"get",
"the",
"oauth",
"data",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L517-L532 | [
"def",
"verify_request",
"(",
"self",
",",
"scopes",
")",
":",
"uri",
",",
"http_method",
",",
"body",
",",
"headers",
"=",
"extract_params",
"(",
")",
"return",
"self",
".",
"server",
".",
"verify_request",
"(",
"uri",
",",
"http_method",
",",
"body",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.token_handler | Access/refresh token handler decorator.
The decorated function should return an dictionary or None as
the extra credentials for creating the token response.
You can control the access method with standard flask route mechanism.
If you only allow the `POST` method::
@app.ro... | flask_oauthlib/provider/oauth2.py | def token_handler(self, f):
"""Access/refresh token handler decorator.
The decorated function should return an dictionary or None as
the extra credentials for creating the token response.
You can control the access method with standard flask route mechanism.
If you only allow t... | def token_handler(self, f):
"""Access/refresh token handler decorator.
The decorated function should return an dictionary or None as
the extra credentials for creating the token response.
You can control the access method with standard flask route mechanism.
If you only allow t... | [
"Access",
"/",
"refresh",
"token",
"handler",
"decorator",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L534-L558 | [
"def",
"token_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"server",
"=",
"self",
".",
"server",
"uri",
",",
"http_method",
",",
"body",
",",
"hea... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.revoke_handler | Access/refresh token revoke decorator.
Any return value by the decorated function will get discarded as
defined in [`RFC7009`_].
You can control the access method with the standard flask routing
mechanism, as per [`RFC7009`_] it is recommended to only allow
the `POST` method::
... | flask_oauthlib/provider/oauth2.py | def revoke_handler(self, f):
"""Access/refresh token revoke decorator.
Any return value by the decorated function will get discarded as
defined in [`RFC7009`_].
You can control the access method with the standard flask routing
mechanism, as per [`RFC7009`_] it is recommended to... | def revoke_handler(self, f):
"""Access/refresh token revoke decorator.
Any return value by the decorated function will get discarded as
defined in [`RFC7009`_].
You can control the access method with the standard flask routing
mechanism, as per [`RFC7009`_] it is recommended to... | [
"Access",
"/",
"refresh",
"token",
"revoke",
"decorator",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L560-L590 | [
"def",
"revoke_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"server",
"=",
"self",
".",
"server",
"token",
"=",
"request",
".",
"values",
".",
"ge... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2Provider.require_oauth | Protect resource with specified scopes. | flask_oauthlib/provider/oauth2.py | def require_oauth(self, *scopes):
"""Protect resource with specified scopes."""
def wrapper(f):
@wraps(f)
def decorated(*args, **kwargs):
for func in self._before_request_funcs:
func()
if hasattr(request, 'oauth') and request.o... | def require_oauth(self, *scopes):
"""Protect resource with specified scopes."""
def wrapper(f):
@wraps(f)
def decorated(*args, **kwargs):
for func in self._before_request_funcs:
func()
if hasattr(request, 'oauth') and request.o... | [
"Protect",
"resource",
"with",
"specified",
"scopes",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L592-L615 | [
"def",
"require_oauth",
"(",
"self",
",",
"*",
"scopes",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func",
"in",
"self",
".",
"_b... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator._get_client_creds_from_request | Return client credentials based on the current request.
According to the rfc6749, client MAY use the HTTP Basic authentication
scheme as defined in [RFC2617] to authenticate with the authorization
server. The client identifier is encoded using the
"application/x-www-form-urlencoded" enc... | flask_oauthlib/provider/oauth2.py | def _get_client_creds_from_request(self, request):
"""Return client credentials based on the current request.
According to the rfc6749, client MAY use the HTTP Basic authentication
scheme as defined in [RFC2617] to authenticate with the authorization
server. The client identifier is enc... | def _get_client_creds_from_request(self, request):
"""Return client credentials based on the current request.
According to the rfc6749, client MAY use the HTTP Basic authentication
scheme as defined in [RFC2617] to authenticate with the authorization
server. The client identifier is enc... | [
"Return",
"client",
"credentials",
"based",
"on",
"the",
"current",
"request",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L636-L661 | [
"def",
"_get_client_creds_from_request",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"client_id",
"is",
"not",
"None",
":",
"return",
"request",
".",
"client_id",
",",
"request",
".",
"client_secret",
"auth",
"=",
"request",
".",
"headers",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.client_authentication_required | Determine if client authentication is required for current request.
According to the rfc6749, client authentication is required in the
following cases:
Resource Owner Password Credentials Grant: see `Section 4.3.2`_.
Authorization Code Grant: see `Section 4.1.3`_.
Refresh Token... | flask_oauthlib/provider/oauth2.py | def client_authentication_required(self, request, *args, **kwargs):
"""Determine if client authentication is required for current request.
According to the rfc6749, client authentication is required in the
following cases:
Resource Owner Password Credentials Grant: see `Section 4.3.2`_... | def client_authentication_required(self, request, *args, **kwargs):
"""Determine if client authentication is required for current request.
According to the rfc6749, client authentication is required in the
following cases:
Resource Owner Password Credentials Grant: see `Section 4.3.2`_... | [
"Determine",
"if",
"client",
"authentication",
"is",
"required",
"for",
"current",
"request",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L663-L691 | [
"def",
"client_authentication_required",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"is_confidential",
"(",
"client",
")",
":",
"if",
"hasattr",
"(",
"client",
",",
"'is_confidential'",
")",
":",
"return",
"cli... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.authenticate_client | Authenticate itself in other means.
Other means means is described in `Section 3.2.1`_.
.. _`Section 3.2.1`: http://tools.ietf.org/html/rfc6749#section-3.2.1 | flask_oauthlib/provider/oauth2.py | def authenticate_client(self, request, *args, **kwargs):
"""Authenticate itself in other means.
Other means means is described in `Section 3.2.1`_.
.. _`Section 3.2.1`: http://tools.ietf.org/html/rfc6749#section-3.2.1
"""
client_id, client_secret = self._get_client_creds_from_r... | def authenticate_client(self, request, *args, **kwargs):
"""Authenticate itself in other means.
Other means means is described in `Section 3.2.1`_.
.. _`Section 3.2.1`: http://tools.ietf.org/html/rfc6749#section-3.2.1
"""
client_id, client_secret = self._get_client_creds_from_r... | [
"Authenticate",
"itself",
"in",
"other",
"means",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L693-L717 | [
"def",
"authenticate_client",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"client_id",
",",
"client_secret",
"=",
"self",
".",
"_get_client_creds_from_request",
"(",
"request",
")",
"log",
".",
"debug",
"(",
"'Authentica... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.authenticate_client_id | Authenticate a non-confidential client.
:param client_id: Client ID of the non-confidential client
:param request: The Request object passed by oauthlib | flask_oauthlib/provider/oauth2.py | def authenticate_client_id(self, client_id, request, *args, **kwargs):
"""Authenticate a non-confidential client.
:param client_id: Client ID of the non-confidential client
:param request: The Request object passed by oauthlib
"""
if client_id is None:
client_id, _ =... | def authenticate_client_id(self, client_id, request, *args, **kwargs):
"""Authenticate a non-confidential client.
:param client_id: Client ID of the non-confidential client
:param request: The Request object passed by oauthlib
"""
if client_id is None:
client_id, _ =... | [
"Authenticate",
"a",
"non",
"-",
"confidential",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L719-L736 | [
"def",
"authenticate_client_id",
"(",
"self",
",",
"client_id",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"client_id",
"is",
"None",
":",
"client_id",
",",
"_",
"=",
"self",
".",
"_get_client_creds_from_request",
"(",
"requ... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.confirm_redirect_uri | Ensure client is authorized to redirect to the redirect_uri.
This method is used in the authorization code grant flow. It will
compare redirect_uri and the one in grant token strictly, you can
add a `validate_redirect_uri` function on grant for a customized
validation. | flask_oauthlib/provider/oauth2.py | def confirm_redirect_uri(self, client_id, code, redirect_uri, client,
*args, **kwargs):
"""Ensure client is authorized to redirect to the redirect_uri.
This method is used in the authorization code grant flow. It will
compare redirect_uri and the one in grant token ... | def confirm_redirect_uri(self, client_id, code, redirect_uri, client,
*args, **kwargs):
"""Ensure client is authorized to redirect to the redirect_uri.
This method is used in the authorization code grant flow. It will
compare redirect_uri and the one in grant token ... | [
"Ensure",
"client",
"is",
"authorized",
"to",
"redirect",
"to",
"the",
"redirect_uri",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L738-L764 | [
"def",
"confirm_redirect_uri",
"(",
"self",
",",
"client_id",
",",
"code",
",",
"redirect_uri",
",",
"client",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"client",
"or",
"self",
".",
"_clientgetter",
"(",
"client_id",
")",
"log",... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.get_original_scopes | Get the list of scopes associated with the refresh token.
This method is used in the refresh token grant flow. We return
the scope of the token to be refreshed so it can be applied to the
new access token. | flask_oauthlib/provider/oauth2.py | def get_original_scopes(self, refresh_token, request, *args, **kwargs):
"""Get the list of scopes associated with the refresh token.
This method is used in the refresh token grant flow. We return
the scope of the token to be refreshed so it can be applied to the
new access token.
... | def get_original_scopes(self, refresh_token, request, *args, **kwargs):
"""Get the list of scopes associated with the refresh token.
This method is used in the refresh token grant flow. We return
the scope of the token to be refreshed so it can be applied to the
new access token.
... | [
"Get",
"the",
"list",
"of",
"scopes",
"associated",
"with",
"the",
"refresh",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L766-L775 | [
"def",
"get_original_scopes",
"(",
"self",
",",
"refresh_token",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Obtaining scope of refreshed token.'",
")",
"tok",
"=",
"self",
".",
"_tokengetter",
"(",
"refre... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.confirm_scopes | Ensures the requested scope matches the scope originally granted
by the resource owner. If the scope is omitted it is treated as equal
to the scope originally granted by the resource owner.
DEPRECATION NOTE: This method will cease to be used in oauthlib>0.4.2,
future versions of ``oauth... | flask_oauthlib/provider/oauth2.py | def confirm_scopes(self, refresh_token, scopes, request, *args, **kwargs):
"""Ensures the requested scope matches the scope originally granted
by the resource owner. If the scope is omitted it is treated as equal
to the scope originally granted by the resource owner.
DEPRECATION NOTE: T... | def confirm_scopes(self, refresh_token, scopes, request, *args, **kwargs):
"""Ensures the requested scope matches the scope originally granted
by the resource owner. If the scope is omitted it is treated as equal
to the scope originally granted by the resource owner.
DEPRECATION NOTE: T... | [
"Ensures",
"the",
"requested",
"scope",
"matches",
"the",
"scope",
"originally",
"granted",
"by",
"the",
"resource",
"owner",
".",
"If",
"the",
"scope",
"is",
"omitted",
"it",
"is",
"treated",
"as",
"equal",
"to",
"the",
"scope",
"originally",
"granted",
"by... | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L777-L792 | [
"def",
"confirm_scopes",
"(",
"self",
",",
"refresh_token",
",",
"scopes",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"scopes",
":",
"log",
".",
"debug",
"(",
"'Scope omitted for refresh token %r'",
",",
"refresh_token"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.get_default_redirect_uri | Default redirect_uri for the given client. | flask_oauthlib/provider/oauth2.py | def get_default_redirect_uri(self, client_id, request, *args, **kwargs):
"""Default redirect_uri for the given client."""
request.client = request.client or self._clientgetter(client_id)
redirect_uri = request.client.default_redirect_uri
log.debug('Found default redirect uri %r', redirec... | def get_default_redirect_uri(self, client_id, request, *args, **kwargs):
"""Default redirect_uri for the given client."""
request.client = request.client or self._clientgetter(client_id)
redirect_uri = request.client.default_redirect_uri
log.debug('Found default redirect uri %r', redirec... | [
"Default",
"redirect_uri",
"for",
"the",
"given",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L794-L799 | [
"def",
"get_default_redirect_uri",
"(",
"self",
",",
"client_id",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
".",
"client",
"=",
"request",
".",
"client",
"or",
"self",
".",
"_clientgetter",
"(",
"client_id",
")",
"re... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.get_default_scopes | Default scopes for the given client. | flask_oauthlib/provider/oauth2.py | def get_default_scopes(self, client_id, request, *args, **kwargs):
"""Default scopes for the given client."""
request.client = request.client or self._clientgetter(client_id)
scopes = request.client.default_scopes
log.debug('Found default scopes %r', scopes)
return scopes | def get_default_scopes(self, client_id, request, *args, **kwargs):
"""Default scopes for the given client."""
request.client = request.client or self._clientgetter(client_id)
scopes = request.client.default_scopes
log.debug('Found default scopes %r', scopes)
return scopes | [
"Default",
"scopes",
"for",
"the",
"given",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L801-L806 | [
"def",
"get_default_scopes",
"(",
"self",
",",
"client_id",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
".",
"client",
"=",
"request",
".",
"client",
"or",
"self",
".",
"_clientgetter",
"(",
"client_id",
")",
"scopes",... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.invalidate_authorization_code | Invalidate an authorization code after use.
We keep the temporary code in a grant, which has a `delete`
function to destroy itself. | flask_oauthlib/provider/oauth2.py | def invalidate_authorization_code(self, client_id, code, request,
*args, **kwargs):
"""Invalidate an authorization code after use.
We keep the temporary code in a grant, which has a `delete`
function to destroy itself.
"""
log.debug('Destroy... | def invalidate_authorization_code(self, client_id, code, request,
*args, **kwargs):
"""Invalidate an authorization code after use.
We keep the temporary code in a grant, which has a `delete`
function to destroy itself.
"""
log.debug('Destroy... | [
"Invalidate",
"an",
"authorization",
"code",
"after",
"use",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L808-L818 | [
"def",
"invalidate_authorization_code",
"(",
"self",
",",
"client_id",
",",
"code",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Destroy grant token for client %r, %r'",
",",
"client_id",
",",
"code",
")",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.save_authorization_code | Persist the authorization code. | flask_oauthlib/provider/oauth2.py | def save_authorization_code(self, client_id, code, request,
*args, **kwargs):
"""Persist the authorization code."""
log.debug(
'Persist authorization code %r for client %r',
code, client_id
)
request.client = request.client or self.... | def save_authorization_code(self, client_id, code, request,
*args, **kwargs):
"""Persist the authorization code."""
log.debug(
'Persist authorization code %r for client %r',
code, client_id
)
request.client = request.client or self.... | [
"Persist",
"the",
"authorization",
"code",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L820-L829 | [
"def",
"save_authorization_code",
"(",
"self",
",",
"client_id",
",",
"code",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Persist authorization code %r for client %r'",
",",
"code",
",",
"client_id",
")",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.save_bearer_token | Persist the Bearer token. | flask_oauthlib/provider/oauth2.py | def save_bearer_token(self, token, request, *args, **kwargs):
"""Persist the Bearer token."""
log.debug('Save bearer token %r', token)
self._tokensetter(token, request, *args, **kwargs)
return request.client.default_redirect_uri | def save_bearer_token(self, token, request, *args, **kwargs):
"""Persist the Bearer token."""
log.debug('Save bearer token %r', token)
self._tokensetter(token, request, *args, **kwargs)
return request.client.default_redirect_uri | [
"Persist",
"the",
"Bearer",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L831-L835 | [
"def",
"save_bearer_token",
"(",
"self",
",",
"token",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Save bearer token %r'",
",",
"token",
")",
"self",
".",
"_tokensetter",
"(",
"token",
",",
"request",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_bearer_token | Validate access token.
:param token: A string of random characters
:param scopes: A list of scopes
:param request: The Request object passed by oauthlib
The validation validates:
1) if the token is available
2) if the token has expired
3) if the sco... | flask_oauthlib/provider/oauth2.py | def validate_bearer_token(self, token, scopes, request):
"""Validate access token.
:param token: A string of random characters
:param scopes: A list of scopes
:param request: The Request object passed by oauthlib
The validation validates:
1) if the token is availab... | def validate_bearer_token(self, token, scopes, request):
"""Validate access token.
:param token: A string of random characters
:param scopes: A list of scopes
:param request: The Request object passed by oauthlib
The validation validates:
1) if the token is availab... | [
"Validate",
"access",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L837-L881 | [
"def",
"validate_bearer_token",
"(",
"self",
",",
"token",
",",
"scopes",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"'Validate bearer token %r'",
",",
"token",
")",
"tok",
"=",
"self",
".",
"_tokengetter",
"(",
"access_token",
"=",
"token",
")",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_client_id | Ensure client_id belong to a valid and active client. | flask_oauthlib/provider/oauth2.py | def validate_client_id(self, client_id, request, *args, **kwargs):
"""Ensure client_id belong to a valid and active client."""
log.debug('Validate client %r', client_id)
client = request.client or self._clientgetter(client_id)
if client:
# attach client to request object
... | def validate_client_id(self, client_id, request, *args, **kwargs):
"""Ensure client_id belong to a valid and active client."""
log.debug('Validate client %r', client_id)
client = request.client or self._clientgetter(client_id)
if client:
# attach client to request object
... | [
"Ensure",
"client_id",
"belong",
"to",
"a",
"valid",
"and",
"active",
"client",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L883-L891 | [
"def",
"validate_client_id",
"(",
"self",
",",
"client_id",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Validate client %r'",
",",
"client_id",
")",
"client",
"=",
"request",
".",
"client",
"or",
"self... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_code | Ensure the grant code is valid. | flask_oauthlib/provider/oauth2.py | def validate_code(self, client_id, code, client, request, *args, **kwargs):
"""Ensure the grant code is valid."""
client = client or self._clientgetter(client_id)
log.debug(
'Validate code for client %r and code %r', client.client_id, code
)
grant = self._grantgetter(... | def validate_code(self, client_id, code, client, request, *args, **kwargs):
"""Ensure the grant code is valid."""
client = client or self._clientgetter(client_id)
log.debug(
'Validate code for client %r and code %r', client.client_id, code
)
grant = self._grantgetter(... | [
"Ensure",
"the",
"grant",
"code",
"is",
"valid",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L893-L911 | [
"def",
"validate_code",
"(",
"self",
",",
"client_id",
",",
"code",
",",
"client",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"client",
"or",
"self",
".",
"_clientgetter",
"(",
"client_id",
")",
"log",
".",
"d... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_grant_type | Ensure the client is authorized to use the grant type requested.
It will allow any of the four grant types (`authorization_code`,
`password`, `client_credentials`, `refresh_token`) by default.
Implemented `allowed_grant_types` for client object to authorize
the request.
It is s... | flask_oauthlib/provider/oauth2.py | def validate_grant_type(self, client_id, grant_type, client, request,
*args, **kwargs):
"""Ensure the client is authorized to use the grant type requested.
It will allow any of the four grant types (`authorization_code`,
`password`, `client_credentials`, `refresh_tok... | def validate_grant_type(self, client_id, grant_type, client, request,
*args, **kwargs):
"""Ensure the client is authorized to use the grant type requested.
It will allow any of the four grant types (`authorization_code`,
`password`, `client_credentials`, `refresh_tok... | [
"Ensure",
"the",
"client",
"is",
"authorized",
"to",
"use",
"the",
"grant",
"type",
"requested",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L913-L949 | [
"def",
"validate_grant_type",
"(",
"self",
",",
"client_id",
",",
"grant_type",
",",
"client",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_usergetter",
"is",
"None",
"and",
"grant_type",
"==",
"'password'",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_redirect_uri | Ensure client is authorized to redirect to the redirect_uri.
This method is used in the authorization code grant flow and also
in implicit grant flow. It will detect if redirect_uri in client's
redirect_uris strictly, you can add a `validate_redirect_uri`
function on grant for a customi... | flask_oauthlib/provider/oauth2.py | def validate_redirect_uri(self, client_id, redirect_uri, request,
*args, **kwargs):
"""Ensure client is authorized to redirect to the redirect_uri.
This method is used in the authorization code grant flow and also
in implicit grant flow. It will detect if redirect_... | def validate_redirect_uri(self, client_id, redirect_uri, request,
*args, **kwargs):
"""Ensure client is authorized to redirect to the redirect_uri.
This method is used in the authorization code grant flow and also
in implicit grant flow. It will detect if redirect_... | [
"Ensure",
"client",
"is",
"authorized",
"to",
"redirect",
"to",
"the",
"redirect_uri",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L951-L964 | [
"def",
"validate_redirect_uri",
"(",
"self",
",",
"client_id",
",",
"redirect_uri",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
".",
"client",
"=",
"request",
".",
"client",
"or",
"self",
".",
"_clientgetter",
"(",
"cl... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_refresh_token | Ensure the token is valid and belongs to the client
This method is used by the authorization code grant indirectly by
issuing refresh tokens, resource owner password credentials grant
(also indirectly) and the refresh token grant. | flask_oauthlib/provider/oauth2.py | def validate_refresh_token(self, refresh_token, client, request,
*args, **kwargs):
"""Ensure the token is valid and belongs to the client
This method is used by the authorization code grant indirectly by
issuing refresh tokens, resource owner password credentials ... | def validate_refresh_token(self, refresh_token, client, request,
*args, **kwargs):
"""Ensure the token is valid and belongs to the client
This method is used by the authorization code grant indirectly by
issuing refresh tokens, resource owner password credentials ... | [
"Ensure",
"the",
"token",
"is",
"valid",
"and",
"belongs",
"to",
"the",
"client"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L966-L982 | [
"def",
"validate_refresh_token",
"(",
"self",
",",
"refresh_token",
",",
"client",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"token",
"=",
"self",
".",
"_tokengetter",
"(",
"refresh_token",
"=",
"refresh_token",
")",
"if",
"token... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_response_type | Ensure client is authorized to use the response type requested.
It will allow any of the two (`code`, `token`) response types by
default. Implemented `allowed_response_types` for client object
to authorize the request. | flask_oauthlib/provider/oauth2.py | def validate_response_type(self, client_id, response_type, client, request,
*args, **kwargs):
"""Ensure client is authorized to use the response type requested.
It will allow any of the two (`code`, `token`) response types by
default. Implemented `allowed_response... | def validate_response_type(self, client_id, response_type, client, request,
*args, **kwargs):
"""Ensure client is authorized to use the response type requested.
It will allow any of the two (`code`, `token`) response types by
default. Implemented `allowed_response... | [
"Ensure",
"client",
"is",
"authorized",
"to",
"use",
"the",
"response",
"type",
"requested",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L984-L997 | [
"def",
"validate_response_type",
"(",
"self",
",",
"client_id",
",",
"response_type",
",",
"client",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"response_type",
"not",
"in",
"(",
"'code'",
",",
"'token'",
")",
":",
"return... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_scopes | Ensure the client is authorized access to requested scopes. | flask_oauthlib/provider/oauth2.py | def validate_scopes(self, client_id, scopes, client, request,
*args, **kwargs):
"""Ensure the client is authorized access to requested scopes."""
if hasattr(client, 'validate_scopes'):
return client.validate_scopes(scopes)
return set(client.default_scopes).iss... | def validate_scopes(self, client_id, scopes, client, request,
*args, **kwargs):
"""Ensure the client is authorized access to requested scopes."""
if hasattr(client, 'validate_scopes'):
return client.validate_scopes(scopes)
return set(client.default_scopes).iss... | [
"Ensure",
"the",
"client",
"is",
"authorized",
"access",
"to",
"requested",
"scopes",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L999-L1004 | [
"def",
"validate_scopes",
"(",
"self",
",",
"client_id",
",",
"scopes",
",",
"client",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"client",
",",
"'validate_scopes'",
")",
":",
"return",
"client",
".",
"va... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.validate_user | Ensure the username and password is valid.
Attach user object on request for later using. | flask_oauthlib/provider/oauth2.py | def validate_user(self, username, password, client, request,
*args, **kwargs):
"""Ensure the username and password is valid.
Attach user object on request for later using.
"""
log.debug('Validating username %r and its password', username)
if self._usergette... | def validate_user(self, username, password, client, request,
*args, **kwargs):
"""Ensure the username and password is valid.
Attach user object on request for later using.
"""
log.debug('Validating username %r and its password', username)
if self._usergette... | [
"Ensure",
"the",
"username",
"and",
"password",
"is",
"valid",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L1006-L1022 | [
"def",
"validate_user",
"(",
"self",
",",
"username",
",",
"password",
",",
"client",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Validating username %r and its password'",
",",
"username",
")",
"if",
"s... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth2RequestValidator.revoke_token | Revoke an access or refresh token. | flask_oauthlib/provider/oauth2.py | def revoke_token(self, token, token_type_hint, request, *args, **kwargs):
"""Revoke an access or refresh token.
"""
if token_type_hint:
tok = self._tokengetter(**{token_type_hint: token})
else:
tok = self._tokengetter(access_token=token)
if not tok:
... | def revoke_token(self, token, token_type_hint, request, *args, **kwargs):
"""Revoke an access or refresh token.
"""
if token_type_hint:
tok = self._tokengetter(**{token_type_hint: token})
else:
tok = self._tokengetter(access_token=token)
if not tok:
... | [
"Revoke",
"an",
"access",
"or",
"refresh",
"token",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth2.py#L1024-L1043 | [
"def",
"revoke_token",
"(",
"self",
",",
"token",
",",
"token_type_hint",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"token_type_hint",
":",
"tok",
"=",
"self",
".",
"_tokengetter",
"(",
"*",
"*",
"{",
"token_type_hint",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | json_to_dict | OAuthResponse class can't parse the JSON data with content-type
- text/html and because of a rubbish api, we can't just tell flask-oauthlib to treat it as json. | example/qq.py | def json_to_dict(x):
'''OAuthResponse class can't parse the JSON data with content-type
- text/html and because of a rubbish api, we can't just tell flask-oauthlib to treat it as json.'''
if x.find(b'callback') > -1:
# the rubbish api (https://graph.qq.com/oauth2.0/authorize) is handled here as speci... | def json_to_dict(x):
'''OAuthResponse class can't parse the JSON data with content-type
- text/html and because of a rubbish api, we can't just tell flask-oauthlib to treat it as json.'''
if x.find(b'callback') > -1:
# the rubbish api (https://graph.qq.com/oauth2.0/authorize) is handled here as speci... | [
"OAuthResponse",
"class",
"can",
"t",
"parse",
"the",
"JSON",
"data",
"with",
"content",
"-",
"type",
"-",
"text",
"/",
"html",
"and",
"because",
"of",
"a",
"rubbish",
"api",
"we",
"can",
"t",
"just",
"tell",
"flask",
"-",
"oauthlib",
"to",
"treat",
"i... | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/example/qq.py#L28-L42 | [
"def",
"json_to_dict",
"(",
"x",
")",
":",
"if",
"x",
".",
"find",
"(",
"b'callback'",
")",
">",
"-",
"1",
":",
"# the rubbish api (https://graph.qq.com/oauth2.0/authorize) is handled here as special case",
"pos_lb",
"=",
"x",
".",
"find",
"(",
"b'{'",
")",
"pos_r... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | update_qq_api_request_data | Update some required parameters for OAuth2.0 API calls | example/qq.py | def update_qq_api_request_data(data={}):
'''Update some required parameters for OAuth2.0 API calls'''
defaults = {
'openid': session.get('qq_openid'),
'access_token': session.get('qq_token')[0],
'oauth_consumer_key': QQ_APP_ID,
}
defaults.update(data)
return defaults | def update_qq_api_request_data(data={}):
'''Update some required parameters for OAuth2.0 API calls'''
defaults = {
'openid': session.get('qq_openid'),
'access_token': session.get('qq_token')[0],
'oauth_consumer_key': QQ_APP_ID,
}
defaults.update(data)
return defaults | [
"Update",
"some",
"required",
"parameters",
"for",
"OAuth2",
".",
"0",
"API",
"calls"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/example/qq.py#L45-L53 | [
"def",
"update_qq_api_request_data",
"(",
"data",
"=",
"{",
"}",
")",
":",
"defaults",
"=",
"{",
"'openid'",
":",
"session",
".",
"get",
"(",
"'qq_openid'",
")",
",",
"'access_token'",
":",
"session",
".",
"get",
"(",
"'qq_token'",
")",
"[",
"0",
"]",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | convert_keys_to_string | Recursively converts dictionary keys to strings. | example/qq.py | def convert_keys_to_string(dictionary):
'''Recursively converts dictionary keys to strings.'''
if not isinstance(dictionary, dict):
return dictionary
return dict((str(k), convert_keys_to_string(v)) for k, v in dictionary.items()) | def convert_keys_to_string(dictionary):
'''Recursively converts dictionary keys to strings.'''
if not isinstance(dictionary, dict):
return dictionary
return dict((str(k), convert_keys_to_string(v)) for k, v in dictionary.items()) | [
"Recursively",
"converts",
"dictionary",
"keys",
"to",
"strings",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/example/qq.py#L107-L111 | [
"def",
"convert_keys_to_string",
"(",
"dictionary",
")",
":",
"if",
"not",
"isinstance",
"(",
"dictionary",
",",
"dict",
")",
":",
"return",
"dictionary",
"return",
"dict",
"(",
"(",
"str",
"(",
"k",
")",
",",
"convert_keys_to_string",
"(",
"v",
")",
")",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | change_weibo_header | Since weibo is a rubbish server, it does not follow the standard,
we need to change the authorization header for it. | flask_oauthlib/contrib/apps.py | def change_weibo_header(uri, headers, body):
"""Since weibo is a rubbish server, it does not follow the standard,
we need to change the authorization header for it."""
auth = headers.get('Authorization')
if auth:
auth = auth.replace('Bearer', 'OAuth2')
headers['Authorization'] = auth
... | def change_weibo_header(uri, headers, body):
"""Since weibo is a rubbish server, it does not follow the standard,
we need to change the authorization header for it."""
auth = headers.get('Authorization')
if auth:
auth = auth.replace('Bearer', 'OAuth2')
headers['Authorization'] = auth
... | [
"Since",
"weibo",
"is",
"a",
"rubbish",
"server",
"it",
"does",
"not",
"follow",
"the",
"standard",
"we",
"need",
"to",
"change",
"the",
"authorization",
"header",
"for",
"it",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/apps.py#L191-L198 | [
"def",
"change_weibo_header",
"(",
"uri",
",",
"headers",
",",
"body",
")",
":",
"auth",
"=",
"headers",
".",
"get",
"(",
"'Authorization'",
")",
"if",
"auth",
":",
"auth",
"=",
"auth",
".",
"replace",
"(",
"'Bearer'",
",",
"'OAuth2'",
")",
"headers",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | RemoteAppFactory.register_to | Creates a remote app and registers it. | flask_oauthlib/contrib/apps.py | def register_to(self, oauth, name=None, **kwargs):
"""Creates a remote app and registers it."""
kwargs = self._process_kwargs(
name=(name or self.default_name), **kwargs)
return oauth.remote_app(**kwargs) | def register_to(self, oauth, name=None, **kwargs):
"""Creates a remote app and registers it."""
kwargs = self._process_kwargs(
name=(name or self.default_name), **kwargs)
return oauth.remote_app(**kwargs) | [
"Creates",
"a",
"remote",
"app",
"and",
"registers",
"it",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/apps.py#L57-L61 | [
"def",
"register_to",
"(",
"self",
",",
"oauth",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"self",
".",
"_process_kwargs",
"(",
"name",
"=",
"(",
"name",
"or",
"self",
".",
"default_name",
")",
",",
"*",
"*",
"kwar... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | RemoteAppFactory.create | Creates a remote app only. | flask_oauthlib/contrib/apps.py | def create(self, oauth, **kwargs):
"""Creates a remote app only."""
kwargs = self._process_kwargs(
name=self.default_name, register=False, **kwargs)
return oauth.remote_app(**kwargs) | def create(self, oauth, **kwargs):
"""Creates a remote app only."""
kwargs = self._process_kwargs(
name=self.default_name, register=False, **kwargs)
return oauth.remote_app(**kwargs) | [
"Creates",
"a",
"remote",
"app",
"only",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/apps.py#L63-L67 | [
"def",
"create",
"(",
"self",
",",
"oauth",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"self",
".",
"_process_kwargs",
"(",
"name",
"=",
"self",
".",
"default_name",
",",
"register",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
"return",
"oauth... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | _get_uri_from_request | The uri returned from request.uri is not properly urlencoded
(sometimes it's partially urldecoded) This is a weird hack to get
werkzeug to return the proper urlencoded string uri | flask_oauthlib/utils.py | def _get_uri_from_request(request):
"""
The uri returned from request.uri is not properly urlencoded
(sometimes it's partially urldecoded) This is a weird hack to get
werkzeug to return the proper urlencoded string uri
"""
uri = request.base_url
if request.query_string:
uri += '?' + ... | def _get_uri_from_request(request):
"""
The uri returned from request.uri is not properly urlencoded
(sometimes it's partially urldecoded) This is a weird hack to get
werkzeug to return the proper urlencoded string uri
"""
uri = request.base_url
if request.query_string:
uri += '?' + ... | [
"The",
"uri",
"returned",
"from",
"request",
".",
"uri",
"is",
"not",
"properly",
"urlencoded",
"(",
"sometimes",
"it",
"s",
"partially",
"urldecoded",
")",
"This",
"is",
"a",
"weird",
"hack",
"to",
"get",
"werkzeug",
"to",
"return",
"the",
"proper",
"urle... | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/utils.py#L8-L17 | [
"def",
"_get_uri_from_request",
"(",
"request",
")",
":",
"uri",
"=",
"request",
".",
"base_url",
"if",
"request",
".",
"query_string",
":",
"uri",
"+=",
"'?'",
"+",
"request",
".",
"query_string",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"uri"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | extract_params | Extract request params. | flask_oauthlib/utils.py | def extract_params():
"""Extract request params."""
uri = _get_uri_from_request(request)
http_method = request.method
headers = dict(request.headers)
if 'wsgi.input' in headers:
del headers['wsgi.input']
if 'wsgi.errors' in headers:
del headers['wsgi.errors']
# Werkzeug, and... | def extract_params():
"""Extract request params."""
uri = _get_uri_from_request(request)
http_method = request.method
headers = dict(request.headers)
if 'wsgi.input' in headers:
del headers['wsgi.input']
if 'wsgi.errors' in headers:
del headers['wsgi.errors']
# Werkzeug, and... | [
"Extract",
"request",
"params",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/utils.py#L20-L37 | [
"def",
"extract_params",
"(",
")",
":",
"uri",
"=",
"_get_uri_from_request",
"(",
"request",
")",
"http_method",
"=",
"request",
".",
"method",
"headers",
"=",
"dict",
"(",
"request",
".",
"headers",
")",
"if",
"'wsgi.input'",
"in",
"headers",
":",
"del",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | to_bytes | Make sure text is bytes type. | flask_oauthlib/utils.py | def to_bytes(text, encoding='utf-8'):
"""Make sure text is bytes type."""
if not text:
return text
if not isinstance(text, bytes_type):
text = text.encode(encoding)
return text | def to_bytes(text, encoding='utf-8'):
"""Make sure text is bytes type."""
if not text:
return text
if not isinstance(text, bytes_type):
text = text.encode(encoding)
return text | [
"Make",
"sure",
"text",
"is",
"bytes",
"type",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/utils.py#L40-L46 | [
"def",
"to_bytes",
"(",
"text",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"not",
"text",
":",
"return",
"text",
"if",
"not",
"isinstance",
"(",
"text",
",",
"bytes_type",
")",
":",
"text",
"=",
"text",
".",
"encode",
"(",
"encoding",
")",
"ret... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | decode_base64 | Decode base64 string. | flask_oauthlib/utils.py | def decode_base64(text, encoding='utf-8'):
"""Decode base64 string."""
text = to_bytes(text, encoding)
return to_unicode(base64.b64decode(text), encoding) | def decode_base64(text, encoding='utf-8'):
"""Decode base64 string."""
text = to_bytes(text, encoding)
return to_unicode(base64.b64decode(text), encoding) | [
"Decode",
"base64",
"string",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/utils.py#L49-L52 | [
"def",
"decode_base64",
"(",
"text",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"text",
"=",
"to_bytes",
"(",
"text",
",",
"encoding",
")",
"return",
"to_unicode",
"(",
"base64",
".",
"b64decode",
"(",
"text",
")",
",",
"encoding",
")"
] | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | create_response | Create response class for Flask. | flask_oauthlib/utils.py | def create_response(headers, body, status):
"""Create response class for Flask."""
response = Response(body or '')
for k, v in headers.items():
response.headers[str(k)] = v
response.status_code = status
return response | def create_response(headers, body, status):
"""Create response class for Flask."""
response = Response(body or '')
for k, v in headers.items():
response.headers[str(k)] = v
response.status_code = status
return response | [
"Create",
"response",
"class",
"for",
"Flask",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/utils.py#L55-L62 | [
"def",
"create_response",
"(",
"headers",
",",
"body",
",",
"status",
")",
":",
"response",
"=",
"Response",
"(",
"body",
"or",
"''",
")",
"for",
"k",
",",
"v",
"in",
"headers",
".",
"items",
"(",
")",
":",
"response",
".",
"headers",
"[",
"str",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | Cache._simple | Returns a :class:`SimpleCache` instance
.. warning::
This cache system might not be thread safe. Use with caution. | flask_oauthlib/contrib/cache.py | def _simple(self, **kwargs):
"""Returns a :class:`SimpleCache` instance
.. warning::
This cache system might not be thread safe. Use with caution.
"""
kwargs.update(dict(threshold=self._config('threshold', 500)))
return SimpleCache(**kwargs) | def _simple(self, **kwargs):
"""Returns a :class:`SimpleCache` instance
.. warning::
This cache system might not be thread safe. Use with caution.
"""
kwargs.update(dict(threshold=self._config('threshold', 500)))
return SimpleCache(**kwargs) | [
"Returns",
"a",
":",
"class",
":",
"SimpleCache",
"instance"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/cache.py#L50-L58 | [
"def",
"_simple",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"dict",
"(",
"threshold",
"=",
"self",
".",
"_config",
"(",
"'threshold'",
",",
"500",
")",
")",
")",
"return",
"SimpleCache",
"(",
"*",
"*",
"kwargs",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | Cache._memcache | Returns a :class:`MemcachedCache` instance | flask_oauthlib/contrib/cache.py | def _memcache(self, **kwargs):
"""Returns a :class:`MemcachedCache` instance"""
kwargs.update(dict(
servers=self._config('MEMCACHED_SERVERS', None),
key_prefix=self._config('key_prefix', None),
))
return MemcachedCache(**kwargs) | def _memcache(self, **kwargs):
"""Returns a :class:`MemcachedCache` instance"""
kwargs.update(dict(
servers=self._config('MEMCACHED_SERVERS', None),
key_prefix=self._config('key_prefix', None),
))
return MemcachedCache(**kwargs) | [
"Returns",
"a",
":",
"class",
":",
"MemcachedCache",
"instance"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/cache.py#L60-L66 | [
"def",
"_memcache",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"dict",
"(",
"servers",
"=",
"self",
".",
"_config",
"(",
"'MEMCACHED_SERVERS'",
",",
"None",
")",
",",
"key_prefix",
"=",
"self",
".",
"_config",
"(",
... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | Cache._redis | Returns a :class:`RedisCache` instance | flask_oauthlib/contrib/cache.py | def _redis(self, **kwargs):
"""Returns a :class:`RedisCache` instance"""
kwargs.update(dict(
host=self._config('REDIS_HOST', 'localhost'),
port=self._config('REDIS_PORT', 6379),
password=self._config('REDIS_PASSWORD', None),
db=self._config('REDIS_DB', 0),... | def _redis(self, **kwargs):
"""Returns a :class:`RedisCache` instance"""
kwargs.update(dict(
host=self._config('REDIS_HOST', 'localhost'),
port=self._config('REDIS_PORT', 6379),
password=self._config('REDIS_PASSWORD', None),
db=self._config('REDIS_DB', 0),... | [
"Returns",
"a",
":",
"class",
":",
"RedisCache",
"instance"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/cache.py#L68-L77 | [
"def",
"_redis",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"dict",
"(",
"host",
"=",
"self",
".",
"_config",
"(",
"'REDIS_HOST'",
",",
"'localhost'",
")",
",",
"port",
"=",
"self",
".",
"_config",
"(",
"'REDIS_PORT... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | Cache._filesystem | Returns a :class:`FileSystemCache` instance | flask_oauthlib/contrib/cache.py | def _filesystem(self, **kwargs):
"""Returns a :class:`FileSystemCache` instance"""
kwargs.update(dict(
threshold=self._config('threshold', 500),
))
return FileSystemCache(self._config('dir', None), **kwargs) | def _filesystem(self, **kwargs):
"""Returns a :class:`FileSystemCache` instance"""
kwargs.update(dict(
threshold=self._config('threshold', 500),
))
return FileSystemCache(self._config('dir', None), **kwargs) | [
"Returns",
"a",
":",
"class",
":",
"FileSystemCache",
"instance"
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/cache.py#L79-L84 | [
"def",
"_filesystem",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"dict",
"(",
"threshold",
"=",
"self",
".",
"_config",
"(",
"'threshold'",
",",
"500",
")",
",",
")",
")",
"return",
"FileSystemCache",
"(",
"self",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | get_cached_clients | Gets the cached clients dictionary in current context. | flask_oauthlib/contrib/client/__init__.py | def get_cached_clients():
"""Gets the cached clients dictionary in current context."""
if OAuth.state_key not in current_app.extensions:
raise RuntimeError('%r is not initialized.' % current_app)
state = current_app.extensions[OAuth.state_key]
return state.cached_clients | def get_cached_clients():
"""Gets the cached clients dictionary in current context."""
if OAuth.state_key not in current_app.extensions:
raise RuntimeError('%r is not initialized.' % current_app)
state = current_app.extensions[OAuth.state_key]
return state.cached_clients | [
"Gets",
"the",
"cached",
"clients",
"dictionary",
"in",
"current",
"context",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/__init__.py#L96-L101 | [
"def",
"get_cached_clients",
"(",
")",
":",
"if",
"OAuth",
".",
"state_key",
"not",
"in",
"current_app",
".",
"extensions",
":",
"raise",
"RuntimeError",
"(",
"'%r is not initialized.'",
"%",
"current_app",
")",
"state",
"=",
"current_app",
".",
"extensions",
"[... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth.add_remote_app | Adds remote application and applies custom attributes on it.
If the application instance's name is different from the argument
provided name, or the keyword arguments is not empty, then the
application instance will not be modified but be copied as a
prototype.
:param remote_ap... | flask_oauthlib/contrib/client/__init__.py | def add_remote_app(self, remote_app, name=None, **kwargs):
"""Adds remote application and applies custom attributes on it.
If the application instance's name is different from the argument
provided name, or the keyword arguments is not empty, then the
application instance will not be mo... | def add_remote_app(self, remote_app, name=None, **kwargs):
"""Adds remote application and applies custom attributes on it.
If the application instance's name is different from the argument
provided name, or the keyword arguments is not empty, then the
application instance will not be mo... | [
"Adds",
"remote",
"application",
"and",
"applies",
"custom",
"attributes",
"on",
"it",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/__init__.py#L34-L55 | [
"def",
"add_remote_app",
"(",
"self",
",",
"remote_app",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"remote_app",
".",
"name",
"if",
"name",
"!=",
"remote_app",
".",
"name",
"or",
"kwarg... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | OAuth.remote_app | Creates and adds new remote application.
:param name: the remote application's name.
:param version: '1' or '2', the version code of OAuth protocol.
:param kwargs: the attributes of remote application. | flask_oauthlib/contrib/client/__init__.py | def remote_app(self, name, version=None, **kwargs):
"""Creates and adds new remote application.
:param name: the remote application's name.
:param version: '1' or '2', the version code of OAuth protocol.
:param kwargs: the attributes of remote application.
"""
if version... | def remote_app(self, name, version=None, **kwargs):
"""Creates and adds new remote application.
:param name: the remote application's name.
:param version: '1' or '2', the version code of OAuth protocol.
:param kwargs: the attributes of remote application.
"""
if version... | [
"Creates",
"and",
"adds",
"new",
"remote",
"application",
"."
] | lepture/flask-oauthlib | python | https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/contrib/client/__init__.py#L57-L75 | [
"def",
"remote_app",
"(",
"self",
",",
"name",
",",
"version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"version",
"is",
"None",
":",
"if",
"'request_token_url'",
"in",
"kwargs",
":",
"version",
"=",
"'1'",
"else",
":",
"version",
"=",
"... | 9e6f152a5bb360e7496210da21561c3e6d41b0e1 |
test | Checker_X509_get_pubkey.check_exception | Call the method repeatedly such that it will raise an exception. | leakcheck/crypto.py | def check_exception(self):
"""
Call the method repeatedly such that it will raise an exception.
"""
for i in xrange(self.iterations):
cert = X509()
try:
cert.get_pubkey()
except Error:
pass | def check_exception(self):
"""
Call the method repeatedly such that it will raise an exception.
"""
for i in xrange(self.iterations):
cert = X509()
try:
cert.get_pubkey()
except Error:
pass | [
"Call",
"the",
"method",
"repeatedly",
"such",
"that",
"it",
"will",
"raise",
"an",
"exception",
"."
] | pyca/pyopenssl | python | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/leakcheck/crypto.py#L24-L33 | [
"def",
"check_exception",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"iterations",
")",
":",
"cert",
"=",
"X509",
"(",
")",
"try",
":",
"cert",
".",
"get_pubkey",
"(",
")",
"except",
"Error",
":",
"pass"
] | 1fbe064c50fd030948141d7d630673761525b0d0 |
test | Checker_X509_get_pubkey.check_success | Call the method repeatedly such that it will return a PKey object. | leakcheck/crypto.py | def check_success(self):
"""
Call the method repeatedly such that it will return a PKey object.
"""
small = xrange(3)
for i in xrange(self.iterations):
key = PKey()
key.generate_key(TYPE_DSA, 256)
for i in small:
cert = X509()
... | def check_success(self):
"""
Call the method repeatedly such that it will return a PKey object.
"""
small = xrange(3)
for i in xrange(self.iterations):
key = PKey()
key.generate_key(TYPE_DSA, 256)
for i in small:
cert = X509()
... | [
"Call",
"the",
"method",
"repeatedly",
"such",
"that",
"it",
"will",
"return",
"a",
"PKey",
"object",
"."
] | pyca/pyopenssl | python | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/leakcheck/crypto.py#L36-L48 | [
"def",
"check_success",
"(",
"self",
")",
":",
"small",
"=",
"xrange",
"(",
"3",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"iterations",
")",
":",
"key",
"=",
"PKey",
"(",
")",
"key",
".",
"generate_key",
"(",
"TYPE_DSA",
",",
"256",
")",
... | 1fbe064c50fd030948141d7d630673761525b0d0 |
test | Checker_load_privatekey.check_load_privatekey_callback | Call the function with an encrypted PEM and a passphrase callback. | leakcheck/crypto.py | def check_load_privatekey_callback(self):
"""
Call the function with an encrypted PEM and a passphrase callback.
"""
for i in xrange(self.iterations * 10):
load_privatekey(
FILETYPE_PEM, self.ENCRYPTED_PEM, lambda *args: "hello, secret") | def check_load_privatekey_callback(self):
"""
Call the function with an encrypted PEM and a passphrase callback.
"""
for i in xrange(self.iterations * 10):
load_privatekey(
FILETYPE_PEM, self.ENCRYPTED_PEM, lambda *args: "hello, secret") | [
"Call",
"the",
"function",
"with",
"an",
"encrypted",
"PEM",
"and",
"a",
"passphrase",
"callback",
"."
] | pyca/pyopenssl | python | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/leakcheck/crypto.py#L70-L76 | [
"def",
"check_load_privatekey_callback",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"iterations",
"*",
"10",
")",
":",
"load_privatekey",
"(",
"FILETYPE_PEM",
",",
"self",
".",
"ENCRYPTED_PEM",
",",
"lambda",
"*",
"args",
":",
"\"... | 1fbe064c50fd030948141d7d630673761525b0d0 |
test | Checker_load_privatekey.check_load_privatekey_callback_incorrect | Call the function with an encrypted PEM and a passphrase callback which
returns the wrong passphrase. | leakcheck/crypto.py | def check_load_privatekey_callback_incorrect(self):
"""
Call the function with an encrypted PEM and a passphrase callback which
returns the wrong passphrase.
"""
for i in xrange(self.iterations * 10):
try:
load_privatekey(
FILETYPE_... | def check_load_privatekey_callback_incorrect(self):
"""
Call the function with an encrypted PEM and a passphrase callback which
returns the wrong passphrase.
"""
for i in xrange(self.iterations * 10):
try:
load_privatekey(
FILETYPE_... | [
"Call",
"the",
"function",
"with",
"an",
"encrypted",
"PEM",
"and",
"a",
"passphrase",
"callback",
"which",
"returns",
"the",
"wrong",
"passphrase",
"."
] | pyca/pyopenssl | python | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/leakcheck/crypto.py#L79-L90 | [
"def",
"check_load_privatekey_callback_incorrect",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"iterations",
"*",
"10",
")",
":",
"try",
":",
"load_privatekey",
"(",
"FILETYPE_PEM",
",",
"self",
".",
"ENCRYPTED_PEM",
",",
"lambda",
"... | 1fbe064c50fd030948141d7d630673761525b0d0 |
test | Checker_load_privatekey.check_load_privatekey_callback_wrong_type | Call the function with an encrypted PEM and a passphrase callback which
returns a non-string. | leakcheck/crypto.py | def check_load_privatekey_callback_wrong_type(self):
"""
Call the function with an encrypted PEM and a passphrase callback which
returns a non-string.
"""
for i in xrange(self.iterations * 10):
try:
load_privatekey(
FILETYPE_PEM, se... | def check_load_privatekey_callback_wrong_type(self):
"""
Call the function with an encrypted PEM and a passphrase callback which
returns a non-string.
"""
for i in xrange(self.iterations * 10):
try:
load_privatekey(
FILETYPE_PEM, se... | [
"Call",
"the",
"function",
"with",
"an",
"encrypted",
"PEM",
"and",
"a",
"passphrase",
"callback",
"which",
"returns",
"a",
"non",
"-",
"string",
"."
] | pyca/pyopenssl | python | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/leakcheck/crypto.py#L93-L104 | [
"def",
"check_load_privatekey_callback_wrong_type",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"iterations",
"*",
"10",
")",
":",
"try",
":",
"load_privatekey",
"(",
"FILETYPE_PEM",
",",
"self",
".",
"ENCRYPTED_PEM",
",",
"lambda",
... | 1fbe064c50fd030948141d7d630673761525b0d0 |
test | Checker_CRL.check_get_revoked | Create a CRL object with 100 Revoked objects, then call the
get_revoked method repeatedly. | leakcheck/crypto.py | def check_get_revoked(self):
"""
Create a CRL object with 100 Revoked objects, then call the
get_revoked method repeatedly.
"""
crl = CRL()
for i in xrange(100):
crl.add_revoked(Revoked())
for i in xrange(self.iterations):
crl.get_revoked() | def check_get_revoked(self):
"""
Create a CRL object with 100 Revoked objects, then call the
get_revoked method repeatedly.
"""
crl = CRL()
for i in xrange(100):
crl.add_revoked(Revoked())
for i in xrange(self.iterations):
crl.get_revoked() | [
"Create",
"a",
"CRL",
"object",
"with",
"100",
"Revoked",
"objects",
"then",
"call",
"the",
"get_revoked",
"method",
"repeatedly",
"."
] | pyca/pyopenssl | python | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/leakcheck/crypto.py#L120-L129 | [
"def",
"check_get_revoked",
"(",
"self",
")",
":",
"crl",
"=",
"CRL",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"100",
")",
":",
"crl",
".",
"add_revoked",
"(",
"Revoked",
"(",
")",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"iterations",
... | 1fbe064c50fd030948141d7d630673761525b0d0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.