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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | GoogleCredentials._get_implicit_credentials | Gets credentials implicitly from the environment.
Checks environment in order of precedence:
- Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
a file with stored credentials information.
- Stored "well known" file associated with `gcloud` command line tool.
- G... | oauth2client/client.py | def _get_implicit_credentials(cls):
"""Gets credentials implicitly from the environment.
Checks environment in order of precedence:
- Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
a file with stored credentials information.
- Stored "well known" file associat... | def _get_implicit_credentials(cls):
"""Gets credentials implicitly from the environment.
Checks environment in order of precedence:
- Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
a file with stored credentials information.
- Stored "well known" file associat... | [
"Gets",
"credentials",
"implicitly",
"from",
"the",
"environment",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1234-L1261 | [
"def",
"_get_implicit_credentials",
"(",
"cls",
")",
":",
"# Environ checks (in order).",
"environ_checkers",
"=",
"[",
"cls",
".",
"_implicit_credentials_from_files",
",",
"cls",
".",
"_implicit_credentials_from_gae",
",",
"cls",
".",
"_implicit_credentials_from_gce",
",",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | GoogleCredentials.from_stream | Create a Credentials object by reading information from a file.
It returns an object of type GoogleCredentials.
Args:
credential_filename: the path to the file from where the
credentials are to be read
Raises:
ApplicationDefaultCredenti... | oauth2client/client.py | def from_stream(credential_filename):
"""Create a Credentials object by reading information from a file.
It returns an object of type GoogleCredentials.
Args:
credential_filename: the path to the file from where the
credentials are to be read
... | def from_stream(credential_filename):
"""Create a Credentials object by reading information from a file.
It returns an object of type GoogleCredentials.
Args:
credential_filename: the path to the file from where the
credentials are to be read
... | [
"Create",
"a",
"Credentials",
"object",
"by",
"reading",
"information",
"from",
"a",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1274-L1300 | [
"def",
"from_stream",
"(",
"credential_filename",
")",
":",
"if",
"credential_filename",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"credential_filename",
")",
":",
"try",
":",
"return",
"_get_application_default_credential_from_file",
"(",
"credential_filename",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DeviceFlowInfo.FromResponse | Create a DeviceFlowInfo from a server response.
The response should be a dict containing entries as described here:
http://tools.ietf.org/html/draft-ietf-oauth-v2-05#section-3.7.1 | oauth2client/client.py | def FromResponse(cls, response):
"""Create a DeviceFlowInfo from a server response.
The response should be a dict containing entries as described here:
http://tools.ietf.org/html/draft-ietf-oauth-v2-05#section-3.7.1
"""
# device_code, user_code, and verification_url are require... | def FromResponse(cls, response):
"""Create a DeviceFlowInfo from a server response.
The response should be a dict containing entries as described here:
http://tools.ietf.org/html/draft-ietf-oauth-v2-05#section-3.7.1
"""
# device_code, user_code, and verification_url are require... | [
"Create",
"a",
"DeviceFlowInfo",
"from",
"a",
"server",
"response",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1746-L1775 | [
"def",
"FromResponse",
"(",
"cls",
",",
"response",
")",
":",
"# device_code, user_code, and verification_url are required.",
"kwargs",
"=",
"{",
"'device_code'",
":",
"response",
"[",
"'device_code'",
"]",
",",
"'user_code'",
":",
"response",
"[",
"'user_code'",
"]",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2WebServerFlow.step1_get_authorize_url | Returns a URI to redirect to the provider.
Args:
redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob'
for a non-web-based application, or a URI that
handles the callback from the authorization server.
This ... | oauth2client/client.py | def step1_get_authorize_url(self, redirect_uri=None, state=None):
"""Returns a URI to redirect to the provider.
Args:
redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob'
for a non-web-based application, or a URI that
handle... | def step1_get_authorize_url(self, redirect_uri=None, state=None):
"""Returns a URI to redirect to the provider.
Args:
redirect_uri: string, Either the string 'urn:ietf:wg:oauth:2.0:oob'
for a non-web-based application, or a URI that
handle... | [
"Returns",
"a",
"URI",
"to",
"redirect",
"to",
"the",
"provider",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1896-L1941 | [
"def",
"step1_get_authorize_url",
"(",
"self",
",",
"redirect_uri",
"=",
"None",
",",
"state",
"=",
"None",
")",
":",
"if",
"redirect_uri",
"is",
"not",
"None",
":",
"logger",
".",
"warning",
"(",
"(",
"'The redirect_uri parameter for '",
"'OAuth2WebServerFlow.ste... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2WebServerFlow.step1_get_device_and_user_codes | Returns a user code and the verification URL where to enter it
Returns:
A user code as a string for the user to authorize the application
An URL as a string where the user has to enter the code | oauth2client/client.py | def step1_get_device_and_user_codes(self, http=None):
"""Returns a user code and the verification URL where to enter it
Returns:
A user code as a string for the user to authorize the application
An URL as a string where the user has to enter the code
"""
if self.... | def step1_get_device_and_user_codes(self, http=None):
"""Returns a user code and the verification URL where to enter it
Returns:
A user code as a string for the user to authorize the application
An URL as a string where the user has to enter the code
"""
if self.... | [
"Returns",
"a",
"user",
"code",
"and",
"the",
"verification",
"URL",
"where",
"to",
"enter",
"it"
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1944-L1989 | [
"def",
"step1_get_device_and_user_codes",
"(",
"self",
",",
"http",
"=",
"None",
")",
":",
"if",
"self",
".",
"device_uri",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'The value of device_uri must not be None.'",
")",
"body",
"=",
"urllib",
".",
"parse",
".... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2WebServerFlow.step2_exchange | Exchanges a code for OAuth2Credentials.
Args:
code: string, a dict-like object, or None. For a non-device
flow, this is either the response code as a string, or a
dictionary of query parameters to the redirect_uri. For a
device flow, this should... | oauth2client/client.py | def step2_exchange(self, code=None, http=None, device_flow_info=None):
"""Exchanges a code for OAuth2Credentials.
Args:
code: string, a dict-like object, or None. For a non-device
flow, this is either the response code as a string, or a
dictionary of quer... | def step2_exchange(self, code=None, http=None, device_flow_info=None):
"""Exchanges a code for OAuth2Credentials.
Args:
code: string, a dict-like object, or None. For a non-device
flow, this is either the response code as a string, or a
dictionary of quer... | [
"Exchanges",
"a",
"code",
"for",
"OAuth2Credentials",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/client.py#L1992-L2089 | [
"def",
"step2_exchange",
"(",
"self",
",",
"code",
"=",
"None",
",",
"http",
"=",
"None",
",",
"device_flow_info",
"=",
"None",
")",
":",
"if",
"code",
"is",
"None",
"and",
"device_flow_info",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'No code or dev... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | RsaVerifier.verify | Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message. If
string, will be encoded to bytes as utf-8... | oauth2client/_pure_python_crypt.py | def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message. If
... | def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message. If
... | [
"Verifies",
"a",
"message",
"against",
"a",
"signature",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pure_python_crypt.py#L75-L92 | [
"def",
"verify",
"(",
"self",
",",
"message",
",",
"signature",
")",
":",
"message",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"message",
",",
"encoding",
"=",
"'utf-8'",
")",
"try",
":",
"return",
"rsa",
".",
"pkcs1",
".",
"verify",
"(",
"message",
",",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | RsaVerifier.from_string | Construct an RsaVerifier instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
Returns:
RsaVerifier instance.
... | oauth2client/_pure_python_crypt.py | def from_string(cls, key_pem, is_x509_cert):
"""Construct an RsaVerifier instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM forma... | def from_string(cls, key_pem, is_x509_cert):
"""Construct an RsaVerifier instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM forma... | [
"Construct",
"an",
"RsaVerifier",
"instance",
"from",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pure_python_crypt.py#L95-L125 | [
"def",
"from_string",
"(",
"cls",
",",
"key_pem",
",",
"is_x509_cert",
")",
":",
"key_pem",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"key_pem",
")",
"if",
"is_x509_cert",
":",
"der",
"=",
"rsa",
".",
"pem",
".",
"load_pem",
"(",
"key_pem",
",",
"'CERTIFIC... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | RsaSigner.sign | Signs a message.
Args:
message: bytes, Message to be signed.
Returns:
string, The signature of the message for the given key. | oauth2client/_pure_python_crypt.py | def sign(self, message):
"""Signs a message.
Args:
message: bytes, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
message = _helpers._to_bytes(message, encoding='utf-8')
return rsa.pkcs1.sign(message, s... | def sign(self, message):
"""Signs a message.
Args:
message: bytes, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
message = _helpers._to_bytes(message, encoding='utf-8')
return rsa.pkcs1.sign(message, s... | [
"Signs",
"a",
"message",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pure_python_crypt.py#L138-L148 | [
"def",
"sign",
"(",
"self",
",",
"message",
")",
":",
"message",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"message",
",",
"encoding",
"=",
"'utf-8'",
")",
"return",
"rsa",
".",
"pkcs1",
".",
"sign",
"(",
"message",
",",
"self",
".",
"_key",
",",
"'SHA... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | RsaSigner.from_string | Construct an RsaSigner instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
RsaSigner instance.
Raises:
ValueError if the key ... | oauth2client/_pure_python_crypt.py | def from_string(cls, key, password='notasecret'):
"""Construct an RsaSigner instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
RsaSigner ... | def from_string(cls, key, password='notasecret'):
"""Construct an RsaSigner instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
RsaSigner ... | [
"Construct",
"an",
"RsaSigner",
"instance",
"from",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pure_python_crypt.py#L151-L184 | [
"def",
"from_string",
"(",
"cls",
",",
"key",
",",
"password",
"=",
"'notasecret'",
")",
":",
"key",
"=",
"_helpers",
".",
"_from_bytes",
"(",
"key",
")",
"# pem expects str in Py3",
"marker_id",
",",
"key_bytes",
"=",
"pem",
".",
"readPemBlocksFromFile",
"(",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _create_file_if_needed | Creates the an empty file if it does not already exist.
Returns:
True if the file was created, False otherwise. | oauth2client/contrib/multiprocess_file_storage.py | def _create_file_if_needed(filename):
"""Creates the an empty file if it does not already exist.
Returns:
True if the file was created, False otherwise.
"""
if os.path.exists(filename):
return False
else:
# Equivalent to "touch".
open(filename, 'a+b').close()
... | def _create_file_if_needed(filename):
"""Creates the an empty file if it does not already exist.
Returns:
True if the file was created, False otherwise.
"""
if os.path.exists(filename):
return False
else:
# Equivalent to "touch".
open(filename, 'a+b').close()
... | [
"Creates",
"the",
"an",
"empty",
"file",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/multiprocess_file_storage.py#L100-L112 | [
"def",
"_create_file_if_needed",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"return",
"False",
"else",
":",
"# Equivalent to \"touch\".",
"open",
"(",
"filename",
",",
"'a+b'",
")",
".",
"close",
"(",
")",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _load_credentials_file | Load credentials from the given file handle.
The file is expected to be in this format:
{
"file_version": 2,
"credentials": {
"key": "base64 encoded json representation of credentials."
}
}
This function will warn and return empty credential... | oauth2client/contrib/multiprocess_file_storage.py | def _load_credentials_file(credentials_file):
"""Load credentials from the given file handle.
The file is expected to be in this format:
{
"file_version": 2,
"credentials": {
"key": "base64 encoded json representation of credentials."
}
}
... | def _load_credentials_file(credentials_file):
"""Load credentials from the given file handle.
The file is expected to be in this format:
{
"file_version": 2,
"credentials": {
"key": "base64 encoded json representation of credentials."
}
}
... | [
"Load",
"credentials",
"from",
"the",
"given",
"file",
"handle",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/multiprocess_file_storage.py#L115-L163 | [
"def",
"_load_credentials_file",
"(",
"credentials_file",
")",
":",
"try",
":",
"credentials_file",
".",
"seek",
"(",
"0",
")",
"data",
"=",
"json",
".",
"load",
"(",
"credentials_file",
")",
"except",
"Exception",
":",
"logger",
".",
"warning",
"(",
"'Crede... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _write_credentials_file | Writes credentials to a file.
Refer to :func:`_load_credentials_file` for the format.
Args:
credentials_file: An open file handle, must be read/write.
credentials: A dictionary mapping user-defined keys to an instance of
:class:`oauth2client.client.Credentials`. | oauth2client/contrib/multiprocess_file_storage.py | def _write_credentials_file(credentials_file, credentials):
"""Writes credentials to a file.
Refer to :func:`_load_credentials_file` for the format.
Args:
credentials_file: An open file handle, must be read/write.
credentials: A dictionary mapping user-defined keys to an instance of
... | def _write_credentials_file(credentials_file, credentials):
"""Writes credentials to a file.
Refer to :func:`_load_credentials_file` for the format.
Args:
credentials_file: An open file handle, must be read/write.
credentials: A dictionary mapping user-defined keys to an instance of
... | [
"Writes",
"credentials",
"to",
"a",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/multiprocess_file_storage.py#L166-L186 | [
"def",
"_write_credentials_file",
"(",
"credentials_file",
",",
"credentials",
")",
":",
"data",
"=",
"{",
"'file_version'",
":",
"2",
",",
"'credentials'",
":",
"{",
"}",
"}",
"for",
"key",
",",
"credential",
"in",
"iteritems",
"(",
"credentials",
")",
":",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _get_backend | A helper method to get or create a backend with thread locking.
This ensures that only one backend is used per-file per-process, so that
thread and process locks are appropriately shared.
Args:
filename: The full path to the credential storage file.
Returns:
An instance of :class:`_Mu... | oauth2client/contrib/multiprocess_file_storage.py | def _get_backend(filename):
"""A helper method to get or create a backend with thread locking.
This ensures that only one backend is used per-file per-process, so that
thread and process locks are appropriately shared.
Args:
filename: The full path to the credential storage file.
Returns:... | def _get_backend(filename):
"""A helper method to get or create a backend with thread locking.
This ensures that only one backend is used per-file per-process, so that
thread and process locks are appropriately shared.
Args:
filename: The full path to the credential storage file.
Returns:... | [
"A",
"helper",
"method",
"to",
"get",
"or",
"create",
"a",
"backend",
"with",
"thread",
"locking",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/multiprocess_file_storage.py#L292-L309 | [
"def",
"_get_backend",
"(",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"with",
"_backends_lock",
":",
"if",
"filename",
"not",
"in",
"_backends",
":",
"_backends",
"[",
"filename",
"]",
"=",
"_Multiproce... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _MultiprocessStorageBackend._load_credentials | (Re-)loads the credentials from the file. | oauth2client/contrib/multiprocess_file_storage.py | def _load_credentials(self):
"""(Re-)loads the credentials from the file."""
if not self._file:
return
loaded_credentials = _load_credentials_file(self._file)
self._credentials.update(loaded_credentials)
logger.debug('Read credential file') | def _load_credentials(self):
"""(Re-)loads the credentials from the file."""
if not self._file:
return
loaded_credentials = _load_credentials_file(self._file)
self._credentials.update(loaded_credentials)
logger.debug('Read credential file') | [
"(",
"Re",
"-",
")",
"loads",
"the",
"credentials",
"from",
"the",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/multiprocess_file_storage.py#L206-L214 | [
"def",
"_load_credentials",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_file",
":",
"return",
"loaded_credentials",
"=",
"_load_credentials_file",
"(",
"self",
".",
"_file",
")",
"self",
".",
"_credentials",
".",
"update",
"(",
"loaded_credentials",
")"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | MultiprocessFileStorage.locked_get | Retrieves the current credentials from the store.
Returns:
An instance of :class:`oauth2client.client.Credentials` or `None`. | oauth2client/contrib/multiprocess_file_storage.py | def locked_get(self):
"""Retrieves the current credentials from the store.
Returns:
An instance of :class:`oauth2client.client.Credentials` or `None`.
"""
credential = self._backend.locked_get(self._key)
if credential is not None:
credential.set_store(se... | def locked_get(self):
"""Retrieves the current credentials from the store.
Returns:
An instance of :class:`oauth2client.client.Credentials` or `None`.
"""
credential = self._backend.locked_get(self._key)
if credential is not None:
credential.set_store(se... | [
"Retrieves",
"the",
"current",
"credentials",
"from",
"the",
"store",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/multiprocess_file_storage.py#L331-L342 | [
"def",
"locked_get",
"(",
"self",
")",
":",
"credential",
"=",
"self",
".",
"_backend",
".",
"locked_get",
"(",
"self",
".",
"_key",
")",
"if",
"credential",
"is",
"not",
"None",
":",
"credential",
".",
"set_store",
"(",
"self",
")",
"return",
"credentia... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | positional | A decorator to declare that only the first N arguments my be positional.
This decorator makes it easy to support Python 3 style keyword-only
parameters. For example, in Python 3 it is possible to write::
def fn(pos1, *, kwonly1=None, kwonly1=None):
...
All named parameters after ``*``... | oauth2client/_helpers.py | def positional(max_positional_args):
"""A decorator to declare that only the first N arguments my be positional.
This decorator makes it easy to support Python 3 style keyword-only
parameters. For example, in Python 3 it is possible to write::
def fn(pos1, *, kwonly1=None, kwonly1=None):
... | def positional(max_positional_args):
"""A decorator to declare that only the first N arguments my be positional.
This decorator makes it easy to support Python 3 style keyword-only
parameters. For example, in Python 3 it is possible to write::
def fn(pos1, *, kwonly1=None, kwonly1=None):
... | [
"A",
"decorator",
"to",
"declare",
"that",
"only",
"the",
"first",
"N",
"arguments",
"my",
"be",
"positional",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_helpers.py#L44-L140 | [
"def",
"positional",
"(",
"max_positional_args",
")",
":",
"def",
"positional_decorator",
"(",
"wrapped",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"wrapped",
")",
"def",
"positional_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | string_to_scopes | Converts stringifed scope value to a list.
If scopes is a list then it is simply passed through. If scopes is an
string then a list of each individual scope is returned.
Args:
scopes: a string or iterable of strings, the scopes.
Returns:
The scopes in a list. | oauth2client/_helpers.py | def string_to_scopes(scopes):
"""Converts stringifed scope value to a list.
If scopes is a list then it is simply passed through. If scopes is an
string then a list of each individual scope is returned.
Args:
scopes: a string or iterable of strings, the scopes.
Returns:
The scopes... | def string_to_scopes(scopes):
"""Converts stringifed scope value to a list.
If scopes is a list then it is simply passed through. If scopes is an
string then a list of each individual scope is returned.
Args:
scopes: a string or iterable of strings, the scopes.
Returns:
The scopes... | [
"Converts",
"stringifed",
"scope",
"value",
"to",
"a",
"list",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_helpers.py#L162-L179 | [
"def",
"string_to_scopes",
"(",
"scopes",
")",
":",
"if",
"not",
"scopes",
":",
"return",
"[",
"]",
"elif",
"isinstance",
"(",
"scopes",
",",
"six",
".",
"string_types",
")",
":",
"return",
"scopes",
".",
"split",
"(",
"' '",
")",
"else",
":",
"return"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | parse_unique_urlencoded | Parses unique key-value parameters from urlencoded content.
Args:
content: string, URL-encoded key-value pairs.
Returns:
dict, The key-value pairs from ``content``.
Raises:
ValueError: if one of the keys is repeated. | oauth2client/_helpers.py | def parse_unique_urlencoded(content):
"""Parses unique key-value parameters from urlencoded content.
Args:
content: string, URL-encoded key-value pairs.
Returns:
dict, The key-value pairs from ``content``.
Raises:
ValueError: if one of the keys is repeated.
"""
urlenco... | def parse_unique_urlencoded(content):
"""Parses unique key-value parameters from urlencoded content.
Args:
content: string, URL-encoded key-value pairs.
Returns:
dict, The key-value pairs from ``content``.
Raises:
ValueError: if one of the keys is repeated.
"""
urlenco... | [
"Parses",
"unique",
"key",
"-",
"value",
"parameters",
"from",
"urlencoded",
"content",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_helpers.py#L182-L202 | [
"def",
"parse_unique_urlencoded",
"(",
"content",
")",
":",
"urlencoded_params",
"=",
"urllib",
".",
"parse",
".",
"parse_qs",
"(",
"content",
")",
"params",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"urlencoded_params",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | update_query_params | Updates a URI with new query parameters.
If a given key from ``params`` is repeated in the ``uri``, then
the URI will be considered invalid and an error will occur.
If the URI is valid, then each value from ``params`` will
replace the corresponding value in the query parameters (if
it exists).
... | oauth2client/_helpers.py | def update_query_params(uri, params):
"""Updates a URI with new query parameters.
If a given key from ``params`` is repeated in the ``uri``, then
the URI will be considered invalid and an error will occur.
If the URI is valid, then each value from ``params`` will
replace the corresponding value in... | def update_query_params(uri, params):
"""Updates a URI with new query parameters.
If a given key from ``params`` is repeated in the ``uri``, then
the URI will be considered invalid and an error will occur.
If the URI is valid, then each value from ``params`` will
replace the corresponding value in... | [
"Updates",
"a",
"URI",
"with",
"new",
"query",
"parameters",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_helpers.py#L205-L227 | [
"def",
"update_query_params",
"(",
"uri",
",",
"params",
")",
":",
"parts",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"uri",
")",
"query_params",
"=",
"parse_unique_urlencoded",
"(",
"parts",
".",
"query",
")",
"query_params",
".",
"update",
"(",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _add_query_parameter | Adds a query parameter to a url.
Replaces the current value if it already exists in the URL.
Args:
url: string, url to add the query parameter to.
name: string, query parameter name.
value: string, query parameter value.
Returns:
Updated query parameter. Does not update th... | oauth2client/_helpers.py | def _add_query_parameter(url, name, value):
"""Adds a query parameter to a url.
Replaces the current value if it already exists in the URL.
Args:
url: string, url to add the query parameter to.
name: string, query parameter name.
value: string, query parameter value.
Returns:
... | def _add_query_parameter(url, name, value):
"""Adds a query parameter to a url.
Replaces the current value if it already exists in the URL.
Args:
url: string, url to add the query parameter to.
name: string, query parameter name.
value: string, query parameter value.
Returns:
... | [
"Adds",
"a",
"query",
"parameter",
"to",
"a",
"url",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_helpers.py#L230-L246 | [
"def",
"_add_query_parameter",
"(",
"url",
",",
"name",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"url",
"else",
":",
"return",
"update_query_params",
"(",
"url",
",",
"{",
"name",
":",
"value",
"}",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _apply_user_agent | Adds a user-agent to the headers.
Args:
headers: dict, request headers to add / modify user
agent within.
user_agent: str, the user agent to add.
Returns:
dict, the original headers passed in, but modified if the
user agent is not None. | oauth2client/transport.py | def _apply_user_agent(headers, user_agent):
"""Adds a user-agent to the headers.
Args:
headers: dict, request headers to add / modify user
agent within.
user_agent: str, the user agent to add.
Returns:
dict, the original headers passed in, but modified if the
... | def _apply_user_agent(headers, user_agent):
"""Adds a user-agent to the headers.
Args:
headers: dict, request headers to add / modify user
agent within.
user_agent: str, the user agent to add.
Returns:
dict, the original headers passed in, but modified if the
... | [
"Adds",
"a",
"user",
"-",
"agent",
"to",
"the",
"headers",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/transport.py#L89-L107 | [
"def",
"_apply_user_agent",
"(",
"headers",
",",
"user_agent",
")",
":",
"if",
"user_agent",
"is",
"not",
"None",
":",
"if",
"'user-agent'",
"in",
"headers",
":",
"headers",
"[",
"'user-agent'",
"]",
"=",
"(",
"user_agent",
"+",
"' '",
"+",
"headers",
"[",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | clean_headers | Forces header keys and values to be strings, i.e not unicode.
The httplib module just concats the header keys and values in a way that
may make the message header a unicode string, which, if it then tries to
contatenate to a binary request body may result in a unicode decode error.
Args:
heade... | oauth2client/transport.py | def clean_headers(headers):
"""Forces header keys and values to be strings, i.e not unicode.
The httplib module just concats the header keys and values in a way that
may make the message header a unicode string, which, if it then tries to
contatenate to a binary request body may result in a unicode dec... | def clean_headers(headers):
"""Forces header keys and values to be strings, i.e not unicode.
The httplib module just concats the header keys and values in a way that
may make the message header a unicode string, which, if it then tries to
contatenate to a binary request body may result in a unicode dec... | [
"Forces",
"header",
"keys",
"and",
"values",
"to",
"be",
"strings",
"i",
".",
"e",
"not",
"unicode",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/transport.py#L110-L134 | [
"def",
"clean_headers",
"(",
"headers",
")",
":",
"clean",
"=",
"{",
"}",
"try",
":",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"headers",
")",
":",
"if",
"not",
"isinstance",
"(",
"k",
",",
"six",
".",
"binary_type",
")",
":",
"k... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | wrap_http_for_auth | Prepares an HTTP object's request method for auth.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
Args:
credentials: Credentials, the credentials u... | oauth2client/transport.py | def wrap_http_for_auth(credentials, http):
"""Prepares an HTTP object's request method for auth.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
Args:
... | def wrap_http_for_auth(credentials, http):
"""Prepares an HTTP object's request method for auth.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
Args:
... | [
"Prepares",
"an",
"HTTP",
"object",
"s",
"request",
"method",
"for",
"auth",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/transport.py#L137-L201 | [
"def",
"wrap_http_for_auth",
"(",
"credentials",
",",
"http",
")",
":",
"orig_request_method",
"=",
"http",
".",
"request",
"# The closure that will replace 'httplib2.Http.request'.",
"def",
"new_request",
"(",
"uri",
",",
"method",
"=",
"'GET'",
",",
"body",
"=",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | wrap_http_for_jwt_access | Prepares an HTTP object's request method for JWT access.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
Args:
credentials: _JWTAccessCredentials, t... | oauth2client/transport.py | def wrap_http_for_jwt_access(credentials, http):
"""Prepares an HTTP object's request method for JWT access.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
... | def wrap_http_for_jwt_access(credentials, http):
"""Prepares an HTTP object's request method for JWT access.
Wraps HTTP requests with logic to catch auth failures (typically
identified via a 401 status code). In the event of failure, tries
to refresh the token used and then retry the original request.
... | [
"Prepares",
"an",
"HTTP",
"object",
"s",
"request",
"method",
"for",
"JWT",
"access",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/transport.py#L204-L251 | [
"def",
"wrap_http_for_jwt_access",
"(",
"credentials",
",",
"http",
")",
":",
"orig_request_method",
"=",
"http",
".",
"request",
"wrap_http_for_auth",
"(",
"credentials",
",",
"http",
")",
"# The new value of ``http.request`` set by ``wrap_http_for_auth``.",
"authenticated_r... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | request | Make an HTTP request with an HTTP object and arguments.
Args:
http: httplib2.Http, an http object to be used to make requests.
uri: string, The URI to be requested.
method: string, The HTTP method to use for the request. Defaults
to 'GET'.
body: string, The payload /... | oauth2client/transport.py | def request(http, uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Make an HTTP request with an HTTP object and arguments.
Args:
http: httplib2.Http, an http object to be used to make requests.
uri: string... | def request(http, uri, method='GET', body=None, headers=None,
redirections=httplib2.DEFAULT_MAX_REDIRECTS,
connection_type=None):
"""Make an HTTP request with an HTTP object and arguments.
Args:
http: httplib2.Http, an http object to be used to make requests.
uri: string... | [
"Make",
"an",
"HTTP",
"request",
"with",
"an",
"HTTP",
"object",
"and",
"arguments",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/transport.py#L254-L282 | [
"def",
"request",
"(",
"http",
",",
"uri",
",",
"method",
"=",
"'GET'",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"redirections",
"=",
"httplib2",
".",
"DEFAULT_MAX_REDIRECTS",
",",
"connection_type",
"=",
"None",
")",
":",
"# NOTE: Allow... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _get_flow_for_token | Retrieves the flow instance associated with a given CSRF token from
the Flask session. | oauth2client/contrib/flask_util.py | def _get_flow_for_token(csrf_token):
"""Retrieves the flow instance associated with a given CSRF token from
the Flask session."""
flow_pickle = session.pop(
_FLOW_KEY.format(csrf_token), None)
if flow_pickle is None:
return None
else:
return pickle.loads(flow_pickle) | def _get_flow_for_token(csrf_token):
"""Retrieves the flow instance associated with a given CSRF token from
the Flask session."""
flow_pickle = session.pop(
_FLOW_KEY.format(csrf_token), None)
if flow_pickle is None:
return None
else:
return pickle.loads(flow_pickle) | [
"Retrieves",
"the",
"flow",
"instance",
"associated",
"with",
"a",
"given",
"CSRF",
"token",
"from",
"the",
"Flask",
"session",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L197-L206 | [
"def",
"_get_flow_for_token",
"(",
"csrf_token",
")",
":",
"flow_pickle",
"=",
"session",
".",
"pop",
"(",
"_FLOW_KEY",
".",
"format",
"(",
"csrf_token",
")",
",",
"None",
")",
"if",
"flow_pickle",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.init_app | Initialize this extension for the given app.
Arguments:
app: A Flask application.
scopes: Optional list of scopes to authorize.
client_secrets_file: Path to a file containing client secrets. You
can also specify the GOOGLE_OAUTH2_CLIENT_SECRETS_FILE config
... | oauth2client/contrib/flask_util.py | def init_app(self, app, scopes=None, client_secrets_file=None,
client_id=None, client_secret=None, authorize_callback=None,
storage=None, **kwargs):
"""Initialize this extension for the given app.
Arguments:
app: A Flask application.
scopes: Opt... | def init_app(self, app, scopes=None, client_secrets_file=None,
client_id=None, client_secret=None, authorize_callback=None,
storage=None, **kwargs):
"""Initialize this extension for the given app.
Arguments:
app: A Flask application.
scopes: Opt... | [
"Initialize",
"this",
"extension",
"for",
"the",
"given",
"app",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L235-L274 | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"scopes",
"=",
"None",
",",
"client_secrets_file",
"=",
"None",
",",
"client_id",
"=",
"None",
",",
"client_secret",
"=",
"None",
",",
"authorize_callback",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2._load_config | Loads oauth2 configuration in order of priority.
Priority:
1. Config passed to the constructor or init_app.
2. Config passed via the GOOGLE_OAUTH2_CLIENT_SECRETS_FILE app
config.
3. Config passed via the GOOGLE_OAUTH2_CLIENT_ID and
GOOGLE_OAUTH2... | oauth2client/contrib/flask_util.py | def _load_config(self, client_secrets_file, client_id, client_secret):
"""Loads oauth2 configuration in order of priority.
Priority:
1. Config passed to the constructor or init_app.
2. Config passed via the GOOGLE_OAUTH2_CLIENT_SECRETS_FILE app
config.
... | def _load_config(self, client_secrets_file, client_id, client_secret):
"""Loads oauth2 configuration in order of priority.
Priority:
1. Config passed to the constructor or init_app.
2. Config passed via the GOOGLE_OAUTH2_CLIENT_SECRETS_FILE app
config.
... | [
"Loads",
"oauth2",
"configuration",
"in",
"order",
"of",
"priority",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L276-L312 | [
"def",
"_load_config",
"(",
"self",
",",
"client_secrets_file",
",",
"client_id",
",",
"client_secret",
")",
":",
"if",
"client_id",
"and",
"client_secret",
":",
"self",
".",
"client_id",
",",
"self",
".",
"client_secret",
"=",
"client_id",
",",
"client_secret",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2._load_client_secrets | Loads client secrets from the given filename. | oauth2client/contrib/flask_util.py | def _load_client_secrets(self, filename):
"""Loads client secrets from the given filename."""
client_type, client_info = clientsecrets.loadfile(filename)
if client_type != clientsecrets.TYPE_WEB:
raise ValueError(
'The flow specified in {0} is not supported.'.format(
... | def _load_client_secrets(self, filename):
"""Loads client secrets from the given filename."""
client_type, client_info = clientsecrets.loadfile(filename)
if client_type != clientsecrets.TYPE_WEB:
raise ValueError(
'The flow specified in {0} is not supported.'.format(
... | [
"Loads",
"client",
"secrets",
"from",
"the",
"given",
"filename",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L314-L323 | [
"def",
"_load_client_secrets",
"(",
"self",
",",
"filename",
")",
":",
"client_type",
",",
"client_info",
"=",
"clientsecrets",
".",
"loadfile",
"(",
"filename",
")",
"if",
"client_type",
"!=",
"clientsecrets",
".",
"TYPE_WEB",
":",
"raise",
"ValueError",
"(",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2._make_flow | Creates a Web Server Flow | oauth2client/contrib/flask_util.py | def _make_flow(self, return_url=None, **kwargs):
"""Creates a Web Server Flow"""
# Generate a CSRF token to prevent malicious requests.
csrf_token = hashlib.sha256(os.urandom(1024)).hexdigest()
session[_CSRF_KEY] = csrf_token
state = json.dumps({
'csrf_token': csrf_... | def _make_flow(self, return_url=None, **kwargs):
"""Creates a Web Server Flow"""
# Generate a CSRF token to prevent malicious requests.
csrf_token = hashlib.sha256(os.urandom(1024)).hexdigest()
session[_CSRF_KEY] = csrf_token
state = json.dumps({
'csrf_token': csrf_... | [
"Creates",
"a",
"Web",
"Server",
"Flow"
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L325-L354 | [
"def",
"_make_flow",
"(",
"self",
",",
"return_url",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Generate a CSRF token to prevent malicious requests.",
"csrf_token",
"=",
"hashlib",
".",
"sha256",
"(",
"os",
".",
"urandom",
"(",
"1024",
")",
")",
".",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.authorize_view | Flask view that starts the authorization flow.
Starts flow by redirecting the user to the OAuth2 provider. | oauth2client/contrib/flask_util.py | def authorize_view(self):
"""Flask view that starts the authorization flow.
Starts flow by redirecting the user to the OAuth2 provider.
"""
args = request.args.to_dict()
# Scopes will be passed as mutliple args, and to_dict() will only
# return one. So, we use getlist()... | def authorize_view(self):
"""Flask view that starts the authorization flow.
Starts flow by redirecting the user to the OAuth2 provider.
"""
args = request.args.to_dict()
# Scopes will be passed as mutliple args, and to_dict() will only
# return one. So, we use getlist()... | [
"Flask",
"view",
"that",
"starts",
"the",
"authorization",
"flow",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L363-L381 | [
"def",
"authorize_view",
"(",
"self",
")",
":",
"args",
"=",
"request",
".",
"args",
".",
"to_dict",
"(",
")",
"# Scopes will be passed as mutliple args, and to_dict() will only",
"# return one. So, we use getlist() to get all of the scopes.",
"args",
"[",
"'scopes'",
"]",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.callback_view | Flask view that handles the user's return from OAuth2 provider.
On return, exchanges the authorization code for credentials and stores
the credentials. | oauth2client/contrib/flask_util.py | def callback_view(self):
"""Flask view that handles the user's return from OAuth2 provider.
On return, exchanges the authorization code for credentials and stores
the credentials.
"""
if 'error' in request.args:
reason = request.args.get(
'error_descr... | def callback_view(self):
"""Flask view that handles the user's return from OAuth2 provider.
On return, exchanges the authorization code for credentials and stores
the credentials.
"""
if 'error' in request.args:
reason = request.args.get(
'error_descr... | [
"Flask",
"view",
"that",
"handles",
"the",
"user",
"s",
"return",
"from",
"OAuth2",
"provider",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L383-L432 | [
"def",
"callback_view",
"(",
"self",
")",
":",
"if",
"'error'",
"in",
"request",
".",
"args",
":",
"reason",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'error_description'",
",",
"request",
".",
"args",
".",
"get",
"(",
"'error'",
",",
"''",
")",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.credentials | The credentials for the current user or None if unavailable. | oauth2client/contrib/flask_util.py | def credentials(self):
"""The credentials for the current user or None if unavailable."""
ctx = _app_ctx_stack.top
if not hasattr(ctx, _CREDENTIALS_KEY):
ctx.google_oauth2_credentials = self.storage.get()
return ctx.google_oauth2_credentials | def credentials(self):
"""The credentials for the current user or None if unavailable."""
ctx = _app_ctx_stack.top
if not hasattr(ctx, _CREDENTIALS_KEY):
ctx.google_oauth2_credentials = self.storage.get()
return ctx.google_oauth2_credentials | [
"The",
"credentials",
"for",
"the",
"current",
"user",
"or",
"None",
"if",
"unavailable",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L435-L442 | [
"def",
"credentials",
"(",
"self",
")",
":",
"ctx",
"=",
"_app_ctx_stack",
".",
"top",
"if",
"not",
"hasattr",
"(",
"ctx",
",",
"_CREDENTIALS_KEY",
")",
":",
"ctx",
".",
"google_oauth2_credentials",
"=",
"self",
".",
"storage",
".",
"get",
"(",
")",
"ret... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.has_credentials | Returns True if there are valid credentials for the current user. | oauth2client/contrib/flask_util.py | def has_credentials(self):
"""Returns True if there are valid credentials for the current user."""
if not self.credentials:
return False
# Is the access token expired? If so, do we have an refresh token?
elif (self.credentials.access_token_expired and
not self... | def has_credentials(self):
"""Returns True if there are valid credentials for the current user."""
if not self.credentials:
return False
# Is the access token expired? If so, do we have an refresh token?
elif (self.credentials.access_token_expired and
not self... | [
"Returns",
"True",
"if",
"there",
"are",
"valid",
"credentials",
"for",
"the",
"current",
"user",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L444-L453 | [
"def",
"has_credentials",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"credentials",
":",
"return",
"False",
"# Is the access token expired? If so, do we have an refresh token?",
"elif",
"(",
"self",
".",
"credentials",
".",
"access_token_expired",
"and",
"not",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.email | Returns the user's email address or None if there are no credentials.
The email address is provided by the current credentials' id_token.
This should not be used as unique identifier as the user can change
their email. If you need a unique identifier, use user_id. | oauth2client/contrib/flask_util.py | def email(self):
"""Returns the user's email address or None if there are no credentials.
The email address is provided by the current credentials' id_token.
This should not be used as unique identifier as the user can change
their email. If you need a unique identifier, use user_id.
... | def email(self):
"""Returns the user's email address or None if there are no credentials.
The email address is provided by the current credentials' id_token.
This should not be used as unique identifier as the user can change
their email. If you need a unique identifier, use user_id.
... | [
"Returns",
"the",
"user",
"s",
"email",
"address",
"or",
"None",
"if",
"there",
"are",
"no",
"credentials",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L456-L469 | [
"def",
"email",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"credentials",
":",
"return",
"None",
"try",
":",
"return",
"self",
".",
"credentials",
".",
"id_token",
"[",
"'email'",
"]",
"except",
"KeyError",
":",
"current_app",
".",
"logger",
".",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | UserOAuth2.required | Decorator to require OAuth2 credentials for a view.
If credentials are not available for the current user, then they will
be redirected to the authorization flow. Once complete, the user will
be redirected back to the original page. | oauth2client/contrib/flask_util.py | def required(self, decorated_function=None, scopes=None,
**decorator_kwargs):
"""Decorator to require OAuth2 credentials for a view.
If credentials are not available for the current user, then they will
be redirected to the authorization flow. Once complete, the user will
... | def required(self, decorated_function=None, scopes=None,
**decorator_kwargs):
"""Decorator to require OAuth2 credentials for a view.
If credentials are not available for the current user, then they will
be redirected to the authorization flow. Once complete, the user will
... | [
"Decorator",
"to",
"require",
"OAuth2",
"credentials",
"for",
"a",
"view",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L498-L539 | [
"def",
"required",
"(",
"self",
",",
"decorated_function",
"=",
"None",
",",
"scopes",
"=",
"None",
",",
"*",
"*",
"decorator_kwargs",
")",
":",
"def",
"curry_wrapper",
"(",
"wrapped_function",
")",
":",
"@",
"wraps",
"(",
"wrapped_function",
")",
"def",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | get | Fetch a resource from the metadata server.
Args:
http: an object to be used to make HTTP requests.
path: A string indicating the resource to retrieve. For example,
'instance/service-accounts/default'
root: A string indicating the full path to the metadata server root.
re... | oauth2client/contrib/_metadata.py | def get(http, path, root=METADATA_ROOT, recursive=None):
"""Fetch a resource from the metadata server.
Args:
http: an object to be used to make HTTP requests.
path: A string indicating the resource to retrieve. For example,
'instance/service-accounts/default'
root: A string ... | def get(http, path, root=METADATA_ROOT, recursive=None):
"""Fetch a resource from the metadata server.
Args:
http: an object to be used to make HTTP requests.
path: A string indicating the resource to retrieve. For example,
'instance/service-accounts/default'
root: A string ... | [
"Fetch",
"a",
"resource",
"from",
"the",
"metadata",
"server",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/_metadata.py#L37-L71 | [
"def",
"get",
"(",
"http",
",",
"path",
",",
"root",
"=",
"METADATA_ROOT",
",",
"recursive",
"=",
"None",
")",
":",
"url",
"=",
"urlparse",
".",
"urljoin",
"(",
"root",
",",
"path",
")",
"url",
"=",
"_helpers",
".",
"_add_query_parameter",
"(",
"url",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | get_token | Fetch an oauth token for the
Args:
http: an object to be used to make HTTP requests.
service_account: An email specifying the service account this token
should represent. Default will be a token for the "default" service
account of the current compute engine instance.
R... | oauth2client/contrib/_metadata.py | def get_token(http, service_account='default'):
"""Fetch an oauth token for the
Args:
http: an object to be used to make HTTP requests.
service_account: An email specifying the service account this token
should represent. Default will be a token for the "default" service
... | def get_token(http, service_account='default'):
"""Fetch an oauth token for the
Args:
http: an object to be used to make HTTP requests.
service_account: An email specifying the service account this token
should represent. Default will be a token for the "default" service
... | [
"Fetch",
"an",
"oauth",
"token",
"for",
"the"
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/_metadata.py#L99-L118 | [
"def",
"get_token",
"(",
"http",
",",
"service_account",
"=",
"'default'",
")",
":",
"token_json",
"=",
"get",
"(",
"http",
",",
"'instance/service-accounts/{0}/token'",
".",
"format",
"(",
"service_account",
")",
")",
"token_expiry",
"=",
"client",
".",
"_UTCNO... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | xsrf_secret_key | Return the secret key for use for XSRF protection.
If the Site entity does not have a secret key, this method will also create
one and persist it.
Returns:
The secret key. | oauth2client/contrib/appengine.py | def xsrf_secret_key():
"""Return the secret key for use for XSRF protection.
If the Site entity does not have a secret key, this method will also create
one and persist it.
Returns:
The secret key.
"""
secret = memcache.get(XSRF_MEMCACHE_ID, namespace=OAUTH2CLIENT_NAMESPACE)
if not... | def xsrf_secret_key():
"""Return the secret key for use for XSRF protection.
If the Site entity does not have a secret key, this method will also create
one and persist it.
Returns:
The secret key.
"""
secret = memcache.get(XSRF_MEMCACHE_ID, namespace=OAUTH2CLIENT_NAMESPACE)
if not... | [
"Return",
"the",
"secret",
"key",
"for",
"use",
"for",
"XSRF",
"protection",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L96-L116 | [
"def",
"xsrf_secret_key",
"(",
")",
":",
"secret",
"=",
"memcache",
".",
"get",
"(",
"XSRF_MEMCACHE_ID",
",",
"namespace",
"=",
"OAUTH2CLIENT_NAMESPACE",
")",
"if",
"not",
"secret",
":",
"# Load the one and only instance of SiteXsrfSecretKey.",
"model",
"=",
"SiteXsrf... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _build_state_value | Composes the value for the 'state' parameter.
Packs the current request URI and an XSRF token into an opaque string that
can be passed to the authentication server via the 'state' parameter.
Args:
request_handler: webapp.RequestHandler, The request.
user: google.appengine.api.users.User, T... | oauth2client/contrib/appengine.py | def _build_state_value(request_handler, user):
"""Composes the value for the 'state' parameter.
Packs the current request URI and an XSRF token into an opaque string that
can be passed to the authentication server via the 'state' parameter.
Args:
request_handler: webapp.RequestHandler, The req... | def _build_state_value(request_handler, user):
"""Composes the value for the 'state' parameter.
Packs the current request URI and an XSRF token into an opaque string that
can be passed to the authentication server via the 'state' parameter.
Args:
request_handler: webapp.RequestHandler, The req... | [
"Composes",
"the",
"value",
"for",
"the",
"state",
"parameter",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L431-L447 | [
"def",
"_build_state_value",
"(",
"request_handler",
",",
"user",
")",
":",
"uri",
"=",
"request_handler",
".",
"request",
".",
"url",
"token",
"=",
"xsrfutil",
".",
"generate_token",
"(",
"xsrf_secret_key",
"(",
")",
",",
"user",
".",
"user_id",
"(",
")",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _parse_state_value | Parse the value of the 'state' parameter.
Parses the value and validates the XSRF token in the state parameter.
Args:
state: string, The value of the state parameter.
user: google.appengine.api.users.User, The current user.
Returns:
The redirect URI, or None if XSRF token is not v... | oauth2client/contrib/appengine.py | def _parse_state_value(state, user):
"""Parse the value of the 'state' parameter.
Parses the value and validates the XSRF token in the state parameter.
Args:
state: string, The value of the state parameter.
user: google.appengine.api.users.User, The current user.
Returns:
The ... | def _parse_state_value(state, user):
"""Parse the value of the 'state' parameter.
Parses the value and validates the XSRF token in the state parameter.
Args:
state: string, The value of the state parameter.
user: google.appengine.api.users.User, The current user.
Returns:
The ... | [
"Parse",
"the",
"value",
"of",
"the",
"state",
"parameter",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L450-L467 | [
"def",
"_parse_state_value",
"(",
"state",
",",
"user",
")",
":",
"uri",
",",
"token",
"=",
"state",
".",
"rsplit",
"(",
"':'",
",",
"1",
")",
"if",
"xsrfutil",
".",
"validate_token",
"(",
"xsrf_secret_key",
"(",
")",
",",
"token",
",",
"user",
".",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | oauth2decorator_from_clientsecrets | Creates an OAuth2Decorator populated from a clientsecrets file.
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) of the credentials being
requested.
message: string, A friendly string to display to the user if the
... | oauth2client/contrib/appengine.py | def oauth2decorator_from_clientsecrets(filename, scope,
message=None, cache=None):
"""Creates an OAuth2Decorator populated from a clientsecrets file.
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) of the cre... | def oauth2decorator_from_clientsecrets(filename, scope,
message=None, cache=None):
"""Creates an OAuth2Decorator populated from a clientsecrets file.
Args:
filename: string, File name of client secrets.
scope: string or list of strings, scope(s) of the cre... | [
"Creates",
"an",
"OAuth2Decorator",
"populated",
"from",
"a",
"clientsecrets",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L892-L910 | [
"def",
"oauth2decorator_from_clientsecrets",
"(",
"filename",
",",
"scope",
",",
"message",
"=",
"None",
",",
"cache",
"=",
"None",
")",
":",
"return",
"OAuth2DecoratorFromClientSecrets",
"(",
"filename",
",",
"scope",
",",
"message",
"=",
"message",
",",
"cache... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | AppAssertionCredentials._refresh | Refreshes the access token.
Since the underlying App Engine app_identity implementation does its
own caching we can skip all the storage hoops and just to a refresh
using the API.
Args:
http: unused HTTP object
Raises:
AccessTokenRefreshError: When the ... | oauth2client/contrib/appengine.py | def _refresh(self, http):
"""Refreshes the access token.
Since the underlying App Engine app_identity implementation does its
own caching we can skip all the storage hoops and just to a refresh
using the API.
Args:
http: unused HTTP object
Raises:
... | def _refresh(self, http):
"""Refreshes the access token.
Since the underlying App Engine app_identity implementation does its
own caching we can skip all the storage hoops and just to a refresh
using the API.
Args:
http: unused HTTP object
Raises:
... | [
"Refreshes",
"the",
"access",
"token",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L158-L177 | [
"def",
"_refresh",
"(",
"self",
",",
"http",
")",
":",
"try",
":",
"scopes",
"=",
"self",
".",
"scope",
".",
"split",
"(",
")",
"(",
"token",
",",
"_",
")",
"=",
"app_identity",
".",
"get_access_token",
"(",
"scopes",
",",
"service_account_id",
"=",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | AppAssertionCredentials.service_account_email | Get the email for the current service account.
Returns:
string, The email associated with the Google App Engine
service account. | oauth2client/contrib/appengine.py | def service_account_email(self):
"""Get the email for the current service account.
Returns:
string, The email associated with the Google App Engine
service account.
"""
if self._service_account_email is None:
self._service_account_email = (
... | def service_account_email(self):
"""Get the email for the current service account.
Returns:
string, The email associated with the Google App Engine
service account.
"""
if self._service_account_email is None:
self._service_account_email = (
... | [
"Get",
"the",
"email",
"for",
"the",
"current",
"service",
"account",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L206-L216 | [
"def",
"service_account_email",
"(",
"self",
")",
":",
"if",
"self",
".",
"_service_account_email",
"is",
"None",
":",
"self",
".",
"_service_account_email",
"=",
"(",
"app_identity",
".",
"get_service_account_name",
"(",
")",
")",
"return",
"self",
".",
"_servi... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | StorageByKeyName._is_ndb | Determine whether the model of the instance is an NDB model.
Returns:
Boolean indicating whether or not the model is an NDB or DB model. | oauth2client/contrib/appengine.py | def _is_ndb(self):
"""Determine whether the model of the instance is an NDB model.
Returns:
Boolean indicating whether or not the model is an NDB or DB model.
"""
# issubclass will fail if one of the arguments is not a class, only
# need worry about new-style classes... | def _is_ndb(self):
"""Determine whether the model of the instance is an NDB model.
Returns:
Boolean indicating whether or not the model is an NDB or DB model.
"""
# issubclass will fail if one of the arguments is not a class, only
# need worry about new-style classes... | [
"Determine",
"whether",
"the",
"model",
"of",
"the",
"instance",
"is",
"an",
"NDB",
"model",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L333-L349 | [
"def",
"_is_ndb",
"(",
"self",
")",
":",
"# issubclass will fail if one of the arguments is not a class, only",
"# need worry about new-style classes since ndb and db models are",
"# new-style",
"if",
"isinstance",
"(",
"self",
".",
"_model",
",",
"type",
")",
":",
"if",
"_ND... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | StorageByKeyName._get_entity | Retrieve entity from datastore.
Uses a different model method for db or ndb models.
Returns:
Instance of the model corresponding to the current storage object
and stored using the key name of the storage object. | oauth2client/contrib/appengine.py | def _get_entity(self):
"""Retrieve entity from datastore.
Uses a different model method for db or ndb models.
Returns:
Instance of the model corresponding to the current storage object
and stored using the key name of the storage object.
"""
if self._is_... | def _get_entity(self):
"""Retrieve entity from datastore.
Uses a different model method for db or ndb models.
Returns:
Instance of the model corresponding to the current storage object
and stored using the key name of the storage object.
"""
if self._is_... | [
"Retrieve",
"entity",
"from",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L351-L363 | [
"def",
"_get_entity",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_ndb",
"(",
")",
":",
"return",
"self",
".",
"_model",
".",
"get_by_id",
"(",
"self",
".",
"_key_name",
")",
"else",
":",
"return",
"self",
".",
"_model",
".",
"get_by_key_name",
"(",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | StorageByKeyName._delete_entity | Delete entity from datastore.
Attempts to delete using the key_name stored on the object, whether or
not the given key is in the datastore. | oauth2client/contrib/appengine.py | def _delete_entity(self):
"""Delete entity from datastore.
Attempts to delete using the key_name stored on the object, whether or
not the given key is in the datastore.
"""
if self._is_ndb():
_NDB_KEY(self._model, self._key_name).delete()
else:
en... | def _delete_entity(self):
"""Delete entity from datastore.
Attempts to delete using the key_name stored on the object, whether or
not the given key is in the datastore.
"""
if self._is_ndb():
_NDB_KEY(self._model, self._key_name).delete()
else:
en... | [
"Delete",
"entity",
"from",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L365-L375 | [
"def",
"_delete_entity",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_ndb",
"(",
")",
":",
"_NDB_KEY",
"(",
"self",
".",
"_model",
",",
"self",
".",
"_key_name",
")",
".",
"delete",
"(",
")",
"else",
":",
"entity_key",
"=",
"db",
".",
"Key",
".",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | StorageByKeyName.locked_get | Retrieve Credential from datastore.
Returns:
oauth2client.Credentials | oauth2client/contrib/appengine.py | def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
credentials = None
if self._cache:
json = self._cache.get(self._key_name)
if json:
credentials = client.Credentials.new_from_jso... | def locked_get(self):
"""Retrieve Credential from datastore.
Returns:
oauth2client.Credentials
"""
credentials = None
if self._cache:
json = self._cache.get(self._key_name)
if json:
credentials = client.Credentials.new_from_jso... | [
"Retrieve",
"Credential",
"from",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L378-L398 | [
"def",
"locked_get",
"(",
"self",
")",
":",
"credentials",
"=",
"None",
"if",
"self",
".",
"_cache",
":",
"json",
"=",
"self",
".",
"_cache",
".",
"get",
"(",
"self",
".",
"_key_name",
")",
"if",
"json",
":",
"credentials",
"=",
"client",
".",
"Crede... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | StorageByKeyName.locked_put | Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store. | oauth2client/contrib/appengine.py | def locked_put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity = self._model.get_or_insert(self._key_name)
setattr(entity, self._property_name, credentials)
entity.put()
... | def locked_put(self, credentials):
"""Write a Credentials to the datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity = self._model.get_or_insert(self._key_name)
setattr(entity, self._property_name, credentials)
entity.put()
... | [
"Write",
"a",
"Credentials",
"to",
"the",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L401-L411 | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"entity",
"=",
"self",
".",
"_model",
".",
"get_or_insert",
"(",
"self",
".",
"_key_name",
")",
"setattr",
"(",
"entity",
",",
"self",
".",
"_property_name",
",",
"credentials",
")",
"entity",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | StorageByKeyName.locked_delete | Delete Credential from datastore. | oauth2client/contrib/appengine.py | def locked_delete(self):
"""Delete Credential from datastore."""
if self._cache:
self._cache.delete(self._key_name)
self._delete_entity() | def locked_delete(self):
"""Delete Credential from datastore."""
if self._cache:
self._cache.delete(self._key_name)
self._delete_entity() | [
"Delete",
"Credential",
"from",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L414-L420 | [
"def",
"locked_delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cache",
":",
"self",
".",
"_cache",
".",
"delete",
"(",
"self",
".",
"_key_name",
")",
"self",
".",
"_delete_entity",
"(",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2Decorator.oauth_required | Decorator that starts the OAuth 2.0 dance.
Starts the OAuth dance for the logged in user if they haven't already
granted access for this application.
Args:
method: callable, to be decorated method of a webapp.RequestHandler
instance. | oauth2client/contrib/appengine.py | def oauth_required(self, method):
"""Decorator that starts the OAuth 2.0 dance.
Starts the OAuth dance for the logged in user if they haven't already
granted access for this application.
Args:
method: callable, to be decorated method of a webapp.RequestHandler
... | def oauth_required(self, method):
"""Decorator that starts the OAuth 2.0 dance.
Starts the OAuth dance for the logged in user if they haven't already
granted access for this application.
Args:
method: callable, to be decorated method of a webapp.RequestHandler
... | [
"Decorator",
"that",
"starts",
"the",
"OAuth",
"2",
".",
"0",
"dance",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L608-L651 | [
"def",
"oauth_required",
"(",
"self",
",",
"method",
")",
":",
"def",
"check_oauth",
"(",
"request_handler",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_in_error",
":",
"self",
".",
"_display_error_message",
"(",
"request_hand... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2Decorator._create_flow | Create the Flow object.
The Flow is calculated lazily since we don't know where this app is
running until it receives a request, at which point redirect_uri can be
calculated and then the Flow object can be constructed.
Args:
request_handler: webapp.RequestHandler, the requ... | oauth2client/contrib/appengine.py | def _create_flow(self, request_handler):
"""Create the Flow object.
The Flow is calculated lazily since we don't know where this app is
running until it receives a request, at which point redirect_uri can be
calculated and then the Flow object can be constructed.
Args:
... | def _create_flow(self, request_handler):
"""Create the Flow object.
The Flow is calculated lazily since we don't know where this app is
running until it receives a request, at which point redirect_uri can be
calculated and then the Flow object can be constructed.
Args:
... | [
"Create",
"the",
"Flow",
"object",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L653-L670 | [
"def",
"_create_flow",
"(",
"self",
",",
"request_handler",
")",
":",
"if",
"self",
".",
"flow",
"is",
"None",
":",
"redirect_uri",
"=",
"request_handler",
".",
"request",
".",
"relative_url",
"(",
"self",
".",
"_callback_path",
")",
"# Usually /oauth2callback",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2Decorator.oauth_aware | Decorator that sets up for OAuth 2.0 dance, but doesn't do it.
Does all the setup for the OAuth dance, but doesn't initiate it.
This decorator is useful if you want to create a page that knows
whether or not the user has granted access to this application.
From within a method decorated... | oauth2client/contrib/appengine.py | def oauth_aware(self, method):
"""Decorator that sets up for OAuth 2.0 dance, but doesn't do it.
Does all the setup for the OAuth dance, but doesn't initiate it.
This decorator is useful if you want to create a page that knows
whether or not the user has granted access to this applicati... | def oauth_aware(self, method):
"""Decorator that sets up for OAuth 2.0 dance, but doesn't do it.
Does all the setup for the OAuth dance, but doesn't initiate it.
This decorator is useful if you want to create a page that knows
whether or not the user has granted access to this applicati... | [
"Decorator",
"that",
"sets",
"up",
"for",
"OAuth",
"2",
".",
"0",
"dance",
"but",
"doesn",
"t",
"do",
"it",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L672-L711 | [
"def",
"oauth_aware",
"(",
"self",
",",
"method",
")",
":",
"def",
"setup_oauth",
"(",
"request_handler",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_in_error",
":",
"self",
".",
"_display_error_message",
"(",
"request_handler... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2Decorator.http | Returns an authorized http instance.
Must only be called from within an @oauth_required decorated method, or
from within an @oauth_aware decorated method where has_credentials()
returns True.
Args:
*args: Positional arguments passed to httplib2.Http constructor.
... | oauth2client/contrib/appengine.py | def http(self, *args, **kwargs):
"""Returns an authorized http instance.
Must only be called from within an @oauth_required decorated method, or
from within an @oauth_aware decorated method where has_credentials()
returns True.
Args:
*args: Positional arguments pass... | def http(self, *args, **kwargs):
"""Returns an authorized http instance.
Must only be called from within an @oauth_required decorated method, or
from within an @oauth_aware decorated method where has_credentials()
returns True.
Args:
*args: Positional arguments pass... | [
"Returns",
"an",
"authorized",
"http",
"instance",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L730-L742 | [
"def",
"http",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"credentials",
".",
"authorize",
"(",
"transport",
".",
"get_http_object",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OAuth2Decorator.callback_handler | RequestHandler for the OAuth 2.0 redirect callback.
Usage::
app = webapp.WSGIApplication([
('/index', MyIndexHandler),
...,
(decorator.callback_path, decorator.callback_handler())
])
Returns:
A webapp.RequestHandler t... | oauth2client/contrib/appengine.py | def callback_handler(self):
"""RequestHandler for the OAuth 2.0 redirect callback.
Usage::
app = webapp.WSGIApplication([
('/index', MyIndexHandler),
...,
(decorator.callback_path, decorator.callback_handler())
])
Returns... | def callback_handler(self):
"""RequestHandler for the OAuth 2.0 redirect callback.
Usage::
app = webapp.WSGIApplication([
('/index', MyIndexHandler),
...,
(decorator.callback_path, decorator.callback_handler())
])
Returns... | [
"RequestHandler",
"for",
"the",
"OAuth",
"2",
".",
"0",
"redirect",
"callback",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/appengine.py#L757-L810 | [
"def",
"callback_handler",
"(",
"self",
")",
":",
"decorator",
"=",
"self",
"class",
"OAuth2Handler",
"(",
"webapp",
".",
"RequestHandler",
")",
":",
"\"\"\"Handler for the redirect_uri of the OAuth 2.0 dance.\"\"\"",
"@",
"login_required",
"def",
"get",
"(",
"self",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | generate_token | Generates a URL-safe token for the given user, action, time tuple.
Args:
key: secret key to use.
user_id: the user ID of the authenticated user.
action_id: a string identifier of the action they requested
authorization for.
when: the time in seconds since the epoc... | oauth2client/contrib/xsrfutil.py | def generate_token(key, user_id, action_id='', when=None):
"""Generates a URL-safe token for the given user, action, time tuple.
Args:
key: secret key to use.
user_id: the user ID of the authenticated user.
action_id: a string identifier of the action they requested
a... | def generate_token(key, user_id, action_id='', when=None):
"""Generates a URL-safe token for the given user, action, time tuple.
Args:
key: secret key to use.
user_id: the user ID of the authenticated user.
action_id: a string identifier of the action they requested
a... | [
"Generates",
"a",
"URL",
"-",
"safe",
"token",
"for",
"the",
"given",
"user",
"action",
"time",
"tuple",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/xsrfutil.py#L33-L57 | [
"def",
"generate_token",
"(",
"key",
",",
"user_id",
",",
"action_id",
"=",
"''",
",",
"when",
"=",
"None",
")",
":",
"digester",
"=",
"hmac",
".",
"new",
"(",
"_helpers",
".",
"_to_bytes",
"(",
"key",
",",
"encoding",
"=",
"'utf-8'",
")",
")",
"dige... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | validate_token | Validates that the given token authorizes the user for the action.
Tokens are invalid if the time of issue is too old or if the token
does not match what generateToken outputs (i.e. the token was forged).
Args:
key: secret key to use.
token: a string of the token generated by generateToken... | oauth2client/contrib/xsrfutil.py | def validate_token(key, token, user_id, action_id="", current_time=None):
"""Validates that the given token authorizes the user for the action.
Tokens are invalid if the time of issue is too old or if the token
does not match what generateToken outputs (i.e. the token was forged).
Args:
key: s... | def validate_token(key, token, user_id, action_id="", current_time=None):
"""Validates that the given token authorizes the user for the action.
Tokens are invalid if the time of issue is too old or if the token
does not match what generateToken outputs (i.e. the token was forged).
Args:
key: s... | [
"Validates",
"that",
"the",
"given",
"token",
"authorizes",
"the",
"user",
"for",
"the",
"action",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/xsrfutil.py#L61-L101 | [
"def",
"validate_token",
"(",
"key",
",",
"token",
",",
"user_id",
",",
"action_id",
"=",
"\"\"",
",",
"current_time",
"=",
"None",
")",
":",
"if",
"not",
"token",
":",
"return",
"False",
"try",
":",
"decoded",
"=",
"base64",
".",
"urlsafe_b64decode",
"(... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _validate_clientsecrets | Validate parsed client secrets from a file.
Args:
clientsecrets_dict: dict, a dictionary holding the client secrets.
Returns:
tuple, a string of the client type and the information parsed
from the file. | oauth2client/clientsecrets.py | def _validate_clientsecrets(clientsecrets_dict):
"""Validate parsed client secrets from a file.
Args:
clientsecrets_dict: dict, a dictionary holding the client secrets.
Returns:
tuple, a string of the client type and the information parsed
from the file.
"""
_INVALID_FILE_F... | def _validate_clientsecrets(clientsecrets_dict):
"""Validate parsed client secrets from a file.
Args:
clientsecrets_dict: dict, a dictionary holding the client secrets.
Returns:
tuple, a string of the client type and the information parsed
from the file.
"""
_INVALID_FILE_F... | [
"Validate",
"parsed",
"client",
"secrets",
"from",
"a",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/clientsecrets.py#L68-L106 | [
"def",
"_validate_clientsecrets",
"(",
"clientsecrets_dict",
")",
":",
"_INVALID_FILE_FORMAT_MSG",
"=",
"(",
"'Invalid file format. See '",
"'https://developers.google.com/api-client-library/'",
"'python/guide/aaa_client_secrets'",
")",
"if",
"clientsecrets_dict",
"is",
"None",
":"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | loadfile | Loading of client_secrets JSON file, optionally backed by a cache.
Typical cache storage would be App Engine memcache service,
but you can pass in any other cache client that implements
these methods:
* ``get(key, namespace=ns)``
* ``set(key, value, namespace=ns)``
Usage::
# without ... | oauth2client/clientsecrets.py | def loadfile(filename, cache=None):
"""Loading of client_secrets JSON file, optionally backed by a cache.
Typical cache storage would be App Engine memcache service,
but you can pass in any other cache client that implements
these methods:
* ``get(key, namespace=ns)``
* ``set(key, value, names... | def loadfile(filename, cache=None):
"""Loading of client_secrets JSON file, optionally backed by a cache.
Typical cache storage would be App Engine memcache service,
but you can pass in any other cache client that implements
these methods:
* ``get(key, namespace=ns)``
* ``set(key, value, names... | [
"Loading",
"of",
"client_secrets",
"JSON",
"file",
"optionally",
"backed",
"by",
"a",
"cache",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/clientsecrets.py#L129-L173 | [
"def",
"loadfile",
"(",
"filename",
",",
"cache",
"=",
"None",
")",
":",
"_SECRET_NAMESPACE",
"=",
"'oauth2client:secrets#ns'",
"if",
"not",
"cache",
":",
"return",
"_loadfile",
"(",
"filename",
")",
"obj",
"=",
"cache",
".",
"get",
"(",
"filename",
",",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _SendRecv | Communicate with the Developer Shell server socket. | oauth2client/contrib/devshell.py | def _SendRecv():
"""Communicate with the Developer Shell server socket."""
port = int(os.getenv(DEVSHELL_ENV, 0))
if port == 0:
raise NoDevshellServer()
sock = socket.socket()
sock.connect(('localhost', port))
data = CREDENTIAL_INFO_REQUEST_JSON
msg = '{0}\n{1}'.format(len(data), ... | def _SendRecv():
"""Communicate with the Developer Shell server socket."""
port = int(os.getenv(DEVSHELL_ENV, 0))
if port == 0:
raise NoDevshellServer()
sock = socket.socket()
sock.connect(('localhost', port))
data = CREDENTIAL_INFO_REQUEST_JSON
msg = '{0}\n{1}'.format(len(data), ... | [
"Communicate",
"with",
"the",
"Developer",
"Shell",
"server",
"socket",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/devshell.py#L72-L94 | [
"def",
"_SendRecv",
"(",
")",
":",
"port",
"=",
"int",
"(",
"os",
".",
"getenv",
"(",
"DEVSHELL_ENV",
",",
"0",
")",
")",
"if",
"port",
"==",
"0",
":",
"raise",
"NoDevshellServer",
"(",
")",
"sock",
"=",
"socket",
".",
"socket",
"(",
")",
"sock",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DevshellCredentials._refresh | Refreshes the access token.
Args:
http: unused HTTP object | oauth2client/contrib/devshell.py | def _refresh(self, http):
"""Refreshes the access token.
Args:
http: unused HTTP object
"""
self.devshell_response = _SendRecv()
self.access_token = self.devshell_response.access_token
expires_in = self.devshell_response.expires_in
if expires_in is no... | def _refresh(self, http):
"""Refreshes the access token.
Args:
http: unused HTTP object
"""
self.devshell_response = _SendRecv()
self.access_token = self.devshell_response.access_token
expires_in = self.devshell_response.expires_in
if expires_in is no... | [
"Refreshes",
"the",
"access",
"token",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/devshell.py#L121-L134 | [
"def",
"_refresh",
"(",
"self",
",",
"http",
")",
":",
"self",
".",
"devshell_response",
"=",
"_SendRecv",
"(",
")",
"self",
".",
"access_token",
"=",
"self",
".",
"devshell_response",
".",
"access_token",
"expires_in",
"=",
"self",
".",
"devshell_response",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | Storage.locked_get | Retrieve Credential from file.
Returns:
oauth2client.client.Credentials | oauth2client/contrib/keyring_storage.py | def locked_get(self):
"""Retrieve Credential from file.
Returns:
oauth2client.client.Credentials
"""
credentials = None
content = keyring.get_password(self._service_name, self._user_name)
if content is not None:
try:
credentials =... | def locked_get(self):
"""Retrieve Credential from file.
Returns:
oauth2client.client.Credentials
"""
credentials = None
content = keyring.get_password(self._service_name, self._user_name)
if content is not None:
try:
credentials =... | [
"Retrieve",
"Credential",
"from",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/keyring_storage.py#L62-L78 | [
"def",
"locked_get",
"(",
"self",
")",
":",
"credentials",
"=",
"None",
"content",
"=",
"keyring",
".",
"get_password",
"(",
"self",
".",
"_service_name",
",",
"self",
".",
"_user_name",
")",
"if",
"content",
"is",
"not",
"None",
":",
"try",
":",
"creden... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | Storage.locked_put | Write Credentials to file.
Args:
credentials: Credentials, the credentials to store. | oauth2client/contrib/keyring_storage.py | def locked_put(self, credentials):
"""Write Credentials to file.
Args:
credentials: Credentials, the credentials to store.
"""
keyring.set_password(self._service_name, self._user_name,
credentials.to_json()) | def locked_put(self, credentials):
"""Write Credentials to file.
Args:
credentials: Credentials, the credentials to store.
"""
keyring.set_password(self._service_name, self._user_name,
credentials.to_json()) | [
"Write",
"Credentials",
"to",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/keyring_storage.py#L80-L87 | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"keyring",
".",
"set_password",
"(",
"self",
".",
"_service_name",
",",
"self",
".",
"_user_name",
",",
"credentials",
".",
"to_json",
"(",
")",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | pkcs12_key_as_pem | Convert the contents of a PKCS#12 key to PEM using pyOpenSSL.
Args:
private_key_bytes: Bytes. PKCS#12 key in DER format.
private_key_password: String. Password for PKCS#12 key.
Returns:
String. PEM contents of ``private_key_bytes``. | oauth2client/_openssl_crypt.py | def pkcs12_key_as_pem(private_key_bytes, private_key_password):
"""Convert the contents of a PKCS#12 key to PEM using pyOpenSSL.
Args:
private_key_bytes: Bytes. PKCS#12 key in DER format.
private_key_password: String. Password for PKCS#12 key.
Returns:
String. PEM contents of ``pri... | def pkcs12_key_as_pem(private_key_bytes, private_key_password):
"""Convert the contents of a PKCS#12 key to PEM using pyOpenSSL.
Args:
private_key_bytes: Bytes. PKCS#12 key in DER format.
private_key_password: String. Password for PKCS#12 key.
Returns:
String. PEM contents of ``pri... | [
"Convert",
"the",
"contents",
"of",
"a",
"PKCS#12",
"key",
"to",
"PEM",
"using",
"pyOpenSSL",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_openssl_crypt.py#L123-L136 | [
"def",
"pkcs12_key_as_pem",
"(",
"private_key_bytes",
",",
"private_key_password",
")",
":",
"private_key_password",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"private_key_password",
")",
"pkcs12",
"=",
"crypto",
".",
"load_pkcs12",
"(",
"private_key_bytes",
",",
"priva... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OpenSSLVerifier.verify | Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message. If string,
will be encoded to bytes as utf-8.
Retur... | oauth2client/_openssl_crypt.py | def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message. If string,
... | def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message. If string,
... | [
"Verifies",
"a",
"message",
"against",
"a",
"signature",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_openssl_crypt.py#L32-L51 | [
"def",
"verify",
"(",
"self",
",",
"message",
",",
"signature",
")",
":",
"message",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"message",
",",
"encoding",
"=",
"'utf-8'",
")",
"signature",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"signature",
",",
"encoding",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OpenSSLVerifier.from_string | Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
Returns:
Verifier instance.
... | oauth2client/_openssl_crypt.py | def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
... | def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
... | [
"Construct",
"a",
"Verified",
"instance",
"from",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_openssl_crypt.py#L54-L73 | [
"def",
"from_string",
"(",
"key_pem",
",",
"is_x509_cert",
")",
":",
"key_pem",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"key_pem",
")",
"if",
"is_x509_cert",
":",
"pubkey",
"=",
"crypto",
".",
"load_certificate",
"(",
"crypto",
".",
"FILETYPE_PEM",
",",
"key... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OpenSSLSigner.sign | Signs a message.
Args:
message: bytes, Message to be signed.
Returns:
string, The signature of the message for the given key. | oauth2client/_openssl_crypt.py | def sign(self, message):
"""Signs a message.
Args:
message: bytes, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
message = _helpers._to_bytes(message, encoding='utf-8')
return crypto.sign(self._key, me... | def sign(self, message):
"""Signs a message.
Args:
message: bytes, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
message = _helpers._to_bytes(message, encoding='utf-8')
return crypto.sign(self._key, me... | [
"Signs",
"a",
"message",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_openssl_crypt.py#L87-L97 | [
"def",
"sign",
"(",
"self",
",",
"message",
")",
":",
"message",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"message",
",",
"encoding",
"=",
"'utf-8'",
")",
"return",
"crypto",
".",
"sign",
"(",
"self",
".",
"_key",
",",
"message",
",",
"'sha256'",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | OpenSSLSigner.from_string | Construct a Signer instance from a string.
Args:
key: string, private key in PKCS12 or PEM format.
password: string, password for the private key file.
Returns:
Signer instance.
Raises:
OpenSSL.crypto.Error if the key can't be parsed. | oauth2client/_openssl_crypt.py | def from_string(key, password=b'notasecret'):
"""Construct a Signer instance from a string.
Args:
key: string, private key in PKCS12 or PEM format.
password: string, password for the private key file.
Returns:
Signer instance.
Raises:
Op... | def from_string(key, password=b'notasecret'):
"""Construct a Signer instance from a string.
Args:
key: string, private key in PKCS12 or PEM format.
password: string, password for the private key file.
Returns:
Signer instance.
Raises:
Op... | [
"Construct",
"a",
"Signer",
"instance",
"from",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_openssl_crypt.py#L100-L120 | [
"def",
"from_string",
"(",
"key",
",",
"password",
"=",
"b'notasecret'",
")",
":",
"key",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"key",
")",
"parsed_pem_key",
"=",
"_helpers",
".",
"_parse_pem_key",
"(",
"key",
")",
"if",
"parsed_pem_key",
":",
"pkey",
"=... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | PyCryptoVerifier.verify | Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message.
Returns:
True if message was signed by the pri... | oauth2client/_pycrypto_crypt.py | def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message.
Returns:
... | def verify(self, message, signature):
"""Verifies a message against a signature.
Args:
message: string or bytes, The message to verify. If string, will be
encoded to bytes as utf-8.
signature: string or bytes, The signature on the message.
Returns:
... | [
"Verifies",
"a",
"message",
"against",
"a",
"signature",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pycrypto_crypt.py#L36-L50 | [
"def",
"verify",
"(",
"self",
",",
"message",
",",
"signature",
")",
":",
"message",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"message",
",",
"encoding",
"=",
"'utf-8'",
")",
"return",
"PKCS1_v1_5",
".",
"new",
"(",
"self",
".",
"_pubkey",
")",
".",
"ve... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | PyCryptoVerifier.from_string | Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
Returns:
Verifier instance. | oauth2client/_pycrypto_crypt.py | def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
... | def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it
is expected to be an RSA key in PEM format.
... | [
"Construct",
"a",
"Verified",
"instance",
"from",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pycrypto_crypt.py#L53-L75 | [
"def",
"from_string",
"(",
"key_pem",
",",
"is_x509_cert",
")",
":",
"if",
"is_x509_cert",
":",
"key_pem",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"key_pem",
")",
"pemLines",
"=",
"key_pem",
".",
"replace",
"(",
"b' '",
",",
"b''",
")",
".",
"split",
"("... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | PyCryptoSigner.sign | Signs a message.
Args:
message: string, Message to be signed.
Returns:
string, The signature of the message for the given key. | oauth2client/_pycrypto_crypt.py | def sign(self, message):
"""Signs a message.
Args:
message: string, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
message = _helpers._to_bytes(message, encoding='utf-8')
return PKCS1_v1_5.new(self._key... | def sign(self, message):
"""Signs a message.
Args:
message: string, Message to be signed.
Returns:
string, The signature of the message for the given key.
"""
message = _helpers._to_bytes(message, encoding='utf-8')
return PKCS1_v1_5.new(self._key... | [
"Signs",
"a",
"message",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pycrypto_crypt.py#L89-L99 | [
"def",
"sign",
"(",
"self",
",",
"message",
")",
":",
"message",
"=",
"_helpers",
".",
"_to_bytes",
"(",
"message",
",",
"encoding",
"=",
"'utf-8'",
")",
"return",
"PKCS1_v1_5",
".",
"new",
"(",
"self",
".",
"_key",
")",
".",
"sign",
"(",
"SHA256",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | PyCryptoSigner.from_string | Construct a Signer instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
Signer instance.
Raises:
NotImplementedError if the ke... | oauth2client/_pycrypto_crypt.py | def from_string(key, password='notasecret'):
"""Construct a Signer instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
Signer instance.
... | def from_string(key, password='notasecret'):
"""Construct a Signer instance from a string.
Args:
key: string, private key in PEM format.
password: string, password for private key file. Unused for PEM
files.
Returns:
Signer instance.
... | [
"Construct",
"a",
"Signer",
"instance",
"from",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pycrypto_crypt.py#L102-L124 | [
"def",
"from_string",
"(",
"key",
",",
"password",
"=",
"'notasecret'",
")",
":",
"parsed_pem_key",
"=",
"_helpers",
".",
"_parse_pem_key",
"(",
"_helpers",
".",
"_to_bytes",
"(",
"key",
")",
")",
"if",
"parsed_pem_key",
":",
"pkey",
"=",
"RSA",
".",
"impo... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | run_flow | Core code for a command-line application.
The ``run()`` function is called from your application and runs
through all the steps to obtain credentials. It takes a ``Flow``
argument and attempts to open an authorization server page in the
user's default web browser. The server asks the user to grant your... | oauth2client/tools.py | def run_flow(flow, storage, flags=None, http=None):
"""Core code for a command-line application.
The ``run()`` function is called from your application and runs
through all the steps to obtain credentials. It takes a ``Flow``
argument and attempts to open an authorization server page in the
user's ... | def run_flow(flow, storage, flags=None, http=None):
"""Core code for a command-line application.
The ``run()`` function is called from your application and runs
through all the steps to obtain credentials. It takes a ``Flow``
argument and attempts to open an authorization server page in the
user's ... | [
"Core",
"code",
"for",
"a",
"command",
"-",
"line",
"application",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/tools.py#L142-L251 | [
"def",
"run_flow",
"(",
"flow",
",",
"storage",
",",
"flags",
"=",
"None",
",",
"http",
"=",
"None",
")",
":",
"if",
"flags",
"is",
"None",
":",
"flags",
"=",
"argparser",
".",
"parse_args",
"(",
")",
"logging",
".",
"getLogger",
"(",
")",
".",
"se... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | ClientRedirectHandler.do_GET | Handle a GET request.
Parses the query parameters and prints a message
if the flow has completed. Note that we can't detect
if an error occurred. | oauth2client/tools.py | def do_GET(self):
"""Handle a GET request.
Parses the query parameters and prints a message
if the flow has completed. Note that we can't detect
if an error occurred.
"""
self.send_response(http_client.OK)
self.send_header('Content-type', 'text/html')
sel... | def do_GET(self):
"""Handle a GET request.
Parses the query parameters and prints a message
if the flow has completed. Note that we can't detect
if an error occurred.
"""
self.send_response(http_client.OK)
self.send_header('Content-type', 'text/html')
sel... | [
"Handle",
"a",
"GET",
"request",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/tools.py#L118-L135 | [
"def",
"do_GET",
"(",
"self",
")",
":",
"self",
".",
"send_response",
"(",
"http_client",
".",
"OK",
")",
"self",
".",
"send_header",
"(",
"'Content-type'",
",",
"'text/html'",
")",
"self",
".",
"end_headers",
"(",
")",
"parts",
"=",
"urllib",
".",
"pars... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | oauth_required | Decorator to require OAuth2 credentials for a view.
.. code-block:: python
:caption: views.py
:name: views_required_2
from oauth2client.django_util.decorators import oauth_required
@oauth_required
def requires_default_scopes(request):
email = request.credentials.id_... | oauth2client/contrib/django_util/decorators.py | def oauth_required(decorated_function=None, scopes=None, **decorator_kwargs):
""" Decorator to require OAuth2 credentials for a view.
.. code-block:: python
:caption: views.py
:name: views_required_2
from oauth2client.django_util.decorators import oauth_required
@oauth_required
... | def oauth_required(decorated_function=None, scopes=None, **decorator_kwargs):
""" Decorator to require OAuth2 credentials for a view.
.. code-block:: python
:caption: views.py
:name: views_required_2
from oauth2client.django_util.decorators import oauth_required
@oauth_required
... | [
"Decorator",
"to",
"require",
"OAuth2",
"credentials",
"for",
"a",
"view",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/decorators.py#L36-L94 | [
"def",
"oauth_required",
"(",
"decorated_function",
"=",
"None",
",",
"scopes",
"=",
"None",
",",
"*",
"*",
"decorator_kwargs",
")",
":",
"def",
"curry_wrapper",
"(",
"wrapped_function",
")",
":",
"@",
"wraps",
"(",
"wrapped_function",
")",
"def",
"required_wr... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | oauth_enabled | Decorator to enable OAuth Credentials if authorized, and setup
the oauth object on the request object to provide helper functions
to start the flow otherwise.
.. code-block:: python
:caption: views.py
:name: views_enabled3
from oauth2client.django_util.decorators import oauth_enabled
... | oauth2client/contrib/django_util/decorators.py | def oauth_enabled(decorated_function=None, scopes=None, **decorator_kwargs):
""" Decorator to enable OAuth Credentials if authorized, and setup
the oauth object on the request object to provide helper functions
to start the flow otherwise.
.. code-block:: python
:caption: views.py
:name: ... | def oauth_enabled(decorated_function=None, scopes=None, **decorator_kwargs):
""" Decorator to enable OAuth Credentials if authorized, and setup
the oauth object on the request object to provide helper functions
to start the flow otherwise.
.. code-block:: python
:caption: views.py
:name: ... | [
"Decorator",
"to",
"enable",
"OAuth",
"Credentials",
"if",
"authorized",
"and",
"setup",
"the",
"oauth",
"object",
"on",
"the",
"request",
"object",
"to",
"provide",
"helper",
"functions",
"to",
"start",
"the",
"flow",
"otherwise",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/decorators.py#L97-L145 | [
"def",
"oauth_enabled",
"(",
"decorated_function",
"=",
"None",
",",
"scopes",
"=",
"None",
",",
"*",
"*",
"decorator_kwargs",
")",
":",
"def",
"curry_wrapper",
"(",
"wrapped_function",
")",
":",
"@",
"wraps",
"(",
"wrapped_function",
")",
"def",
"enabled_wrap... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | code_verifier | Generates a 'code_verifier' as described in section 4.1 of RFC 7636.
This is a 'high-entropy cryptographic random string' that will be
impractical for an attacker to guess.
Args:
n_bytes: integer between 31 and 96, inclusive. default: 64
number of bytes of entropy to include in verifie... | oauth2client/_pkce.py | def code_verifier(n_bytes=64):
"""
Generates a 'code_verifier' as described in section 4.1 of RFC 7636.
This is a 'high-entropy cryptographic random string' that will be
impractical for an attacker to guess.
Args:
n_bytes: integer between 31 and 96, inclusive. default: 64
numbe... | def code_verifier(n_bytes=64):
"""
Generates a 'code_verifier' as described in section 4.1 of RFC 7636.
This is a 'high-entropy cryptographic random string' that will be
impractical for an attacker to guess.
Args:
n_bytes: integer between 31 and 96, inclusive. default: 64
numbe... | [
"Generates",
"a",
"code_verifier",
"as",
"described",
"in",
"section",
"4",
".",
"1",
"of",
"RFC",
"7636",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pkce.py#L27-L49 | [
"def",
"code_verifier",
"(",
"n_bytes",
"=",
"64",
")",
":",
"verifier",
"=",
"base64",
".",
"urlsafe_b64encode",
"(",
"os",
".",
"urandom",
"(",
"n_bytes",
")",
")",
".",
"rstrip",
"(",
"b'='",
")",
"# https://tools.ietf.org/html/rfc7636#section-4.1",
"# minimu... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | code_challenge | Creates a 'code_challenge' as described in section 4.2 of RFC 7636
by taking the sha256 hash of the verifier and then urlsafe
base64-encoding it.
Args:
verifier: bytestring, representing a code_verifier as generated by
code_verifier().
Returns:
Bytestring, representing a ur... | oauth2client/_pkce.py | def code_challenge(verifier):
"""
Creates a 'code_challenge' as described in section 4.2 of RFC 7636
by taking the sha256 hash of the verifier and then urlsafe
base64-encoding it.
Args:
verifier: bytestring, representing a code_verifier as generated by
code_verifier().
Retu... | def code_challenge(verifier):
"""
Creates a 'code_challenge' as described in section 4.2 of RFC 7636
by taking the sha256 hash of the verifier and then urlsafe
base64-encoding it.
Args:
verifier: bytestring, representing a code_verifier as generated by
code_verifier().
Retu... | [
"Creates",
"a",
"code_challenge",
"as",
"described",
"in",
"section",
"4",
".",
"2",
"of",
"RFC",
"7636",
"by",
"taking",
"the",
"sha256",
"hash",
"of",
"the",
"verifier",
"and",
"then",
"urlsafe",
"base64",
"-",
"encoding",
"it",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pkce.py#L52-L67 | [
"def",
"code_challenge",
"(",
"verifier",
")",
":",
"digest",
"=",
"hashlib",
".",
"sha256",
"(",
"verifier",
")",
".",
"digest",
"(",
")",
"return",
"base64",
".",
"urlsafe_b64encode",
"(",
"digest",
")",
".",
"rstrip",
"(",
"b'='",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | AppAssertionCredentials._retrieve_info | Retrieves service account info for invalid credentials.
Args:
http: an object to be used to make HTTP requests. | oauth2client/contrib/gce.py | def _retrieve_info(self, http):
"""Retrieves service account info for invalid credentials.
Args:
http: an object to be used to make HTTP requests.
"""
if self.invalid:
info = _metadata.get_service_account_info(
http,
service_accoun... | def _retrieve_info(self, http):
"""Retrieves service account info for invalid credentials.
Args:
http: an object to be used to make HTTP requests.
"""
if self.invalid:
info = _metadata.get_service_account_info(
http,
service_accoun... | [
"Retrieves",
"service",
"account",
"info",
"for",
"invalid",
"credentials",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/gce.py#L102-L114 | [
"def",
"_retrieve_info",
"(",
"self",
",",
"http",
")",
":",
"if",
"self",
".",
"invalid",
":",
"info",
"=",
"_metadata",
".",
"get_service_account_info",
"(",
"http",
",",
"service_account",
"=",
"self",
".",
"service_account_email",
"or",
"'default'",
")",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | AppAssertionCredentials._refresh | Refreshes the access token.
Skip all the storage hoops and just refresh using the API.
Args:
http: an object to be used to make HTTP requests.
Raises:
HttpAccessTokenRefreshError: When the refresh fails. | oauth2client/contrib/gce.py | def _refresh(self, http):
"""Refreshes the access token.
Skip all the storage hoops and just refresh using the API.
Args:
http: an object to be used to make HTTP requests.
Raises:
HttpAccessTokenRefreshError: When the refresh fails.
"""
try:
... | def _refresh(self, http):
"""Refreshes the access token.
Skip all the storage hoops and just refresh using the API.
Args:
http: an object to be used to make HTTP requests.
Raises:
HttpAccessTokenRefreshError: When the refresh fails.
"""
try:
... | [
"Refreshes",
"the",
"access",
"token",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/gce.py#L116-L132 | [
"def",
"_refresh",
"(",
"self",
",",
"http",
")",
":",
"try",
":",
"self",
".",
"_retrieve_info",
"(",
"http",
")",
"self",
".",
"access_token",
",",
"self",
".",
"token_expiry",
"=",
"_metadata",
".",
"get_token",
"(",
"http",
",",
"service_account",
"=... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DjangoORMStorage.locked_get | Retrieve stored credential from the Django ORM.
Returns:
oauth2client.Credentials retrieved from the Django ORM, associated
with the ``model``, ``key_value``->``key_name`` pair used to query
for the model, and ``property_name`` identifying the
``CredentialsPro... | oauth2client/contrib/django_util/storage.py | def locked_get(self):
"""Retrieve stored credential from the Django ORM.
Returns:
oauth2client.Credentials retrieved from the Django ORM, associated
with the ``model``, ``key_value``->``key_name`` pair used to query
for the model, and ``property_name`` identifying ... | def locked_get(self):
"""Retrieve stored credential from the Django ORM.
Returns:
oauth2client.Credentials retrieved from the Django ORM, associated
with the ``model``, ``key_value``->``key_name`` pair used to query
for the model, and ``property_name`` identifying ... | [
"Retrieve",
"stored",
"credential",
"from",
"the",
"Django",
"ORM",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/storage.py#L45-L64 | [
"def",
"locked_get",
"(",
"self",
")",
":",
"query",
"=",
"{",
"self",
".",
"key_name",
":",
"self",
".",
"key_value",
"}",
"entities",
"=",
"self",
".",
"model_class",
".",
"objects",
".",
"filter",
"(",
"*",
"*",
"query",
")",
"if",
"len",
"(",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DjangoORMStorage.locked_put | Write a Credentials to the Django datastore.
Args:
credentials: Credentials, the credentials to store. | oauth2client/contrib/django_util/storage.py | def locked_put(self, credentials):
"""Write a Credentials to the Django datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity, _ = self.model_class.objects.get_or_create(
**{self.key_name: self.key_value})
setattr(entity, self.p... | def locked_put(self, credentials):
"""Write a Credentials to the Django datastore.
Args:
credentials: Credentials, the credentials to store.
"""
entity, _ = self.model_class.objects.get_or_create(
**{self.key_name: self.key_value})
setattr(entity, self.p... | [
"Write",
"a",
"Credentials",
"to",
"the",
"Django",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/storage.py#L66-L76 | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"entity",
",",
"_",
"=",
"self",
".",
"model_class",
".",
"objects",
".",
"get_or_create",
"(",
"*",
"*",
"{",
"self",
".",
"key_name",
":",
"self",
".",
"key_value",
"}",
")",
"setattr",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DjangoORMStorage.locked_delete | Delete Credentials from the datastore. | oauth2client/contrib/django_util/storage.py | def locked_delete(self):
"""Delete Credentials from the datastore."""
query = {self.key_name: self.key_value}
self.model_class.objects.filter(**query).delete() | def locked_delete(self):
"""Delete Credentials from the datastore."""
query = {self.key_name: self.key_value}
self.model_class.objects.filter(**query).delete() | [
"Delete",
"Credentials",
"from",
"the",
"datastore",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/storage.py#L78-L81 | [
"def",
"locked_delete",
"(",
"self",
")",
":",
"query",
"=",
"{",
"self",
".",
"key_name",
":",
"self",
".",
"key_value",
"}",
"self",
".",
"model_class",
".",
"objects",
".",
"filter",
"(",
"*",
"*",
"query",
")",
".",
"delete",
"(",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DictionaryStorage.locked_get | Retrieve the credentials from the dictionary, if they exist.
Returns: A :class:`oauth2client.client.OAuth2Credentials` instance. | oauth2client/contrib/dictionary_storage.py | def locked_get(self):
"""Retrieve the credentials from the dictionary, if they exist.
Returns: A :class:`oauth2client.client.OAuth2Credentials` instance.
"""
serialized = self._dictionary.get(self._key)
if serialized is None:
return None
credentials = clien... | def locked_get(self):
"""Retrieve the credentials from the dictionary, if they exist.
Returns: A :class:`oauth2client.client.OAuth2Credentials` instance.
"""
serialized = self._dictionary.get(self._key)
if serialized is None:
return None
credentials = clien... | [
"Retrieve",
"the",
"credentials",
"from",
"the",
"dictionary",
"if",
"they",
"exist",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/dictionary_storage.py#L38-L51 | [
"def",
"locked_get",
"(",
"self",
")",
":",
"serialized",
"=",
"self",
".",
"_dictionary",
".",
"get",
"(",
"self",
".",
"_key",
")",
"if",
"serialized",
"is",
"None",
":",
"return",
"None",
"credentials",
"=",
"client",
".",
"OAuth2Credentials",
".",
"f... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | DictionaryStorage.locked_put | Save the credentials to the dictionary.
Args:
credentials: A :class:`oauth2client.client.OAuth2Credentials`
instance. | oauth2client/contrib/dictionary_storage.py | def locked_put(self, credentials):
"""Save the credentials to the dictionary.
Args:
credentials: A :class:`oauth2client.client.OAuth2Credentials`
instance.
"""
serialized = credentials.to_json()
self._dictionary[self._key] = serialized | def locked_put(self, credentials):
"""Save the credentials to the dictionary.
Args:
credentials: A :class:`oauth2client.client.OAuth2Credentials`
instance.
"""
serialized = credentials.to_json()
self._dictionary[self._key] = serialized | [
"Save",
"the",
"credentials",
"to",
"the",
"dictionary",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/dictionary_storage.py#L53-L61 | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"serialized",
"=",
"credentials",
".",
"to_json",
"(",
")",
"self",
".",
"_dictionary",
"[",
"self",
".",
"_key",
"]",
"=",
"serialized"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | FlowNDBProperty._validate | Validates a value as a proper Flow object.
Args:
value: A value to be set on the property.
Raises:
TypeError if the value is not an instance of Flow. | oauth2client/contrib/_appengine_ndb.py | def _validate(self, value):
"""Validates a value as a proper Flow object.
Args:
value: A value to be set on the property.
Raises:
TypeError if the value is not an instance of Flow.
"""
_LOGGER.info('validate: Got type %s', type(value))
if value i... | def _validate(self, value):
"""Validates a value as a proper Flow object.
Args:
value: A value to be set on the property.
Raises:
TypeError if the value is not an instance of Flow.
"""
_LOGGER.info('validate: Got type %s', type(value))
if value i... | [
"Validates",
"a",
"value",
"as",
"a",
"proper",
"Flow",
"object",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/_appengine_ndb.py#L68-L81 | [
"def",
"_validate",
"(",
"self",
",",
"value",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'validate: Got type %s'",
",",
"type",
"(",
"value",
")",
")",
"if",
"value",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"client",
".",
"Flo... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | CredentialsNDBProperty._from_base_type | Converts our stored JSON string back to the desired type.
Args:
value: A value from the datastore to be converted to the
desired type.
Returns:
A deserialized Credentials (or subclass) object, else None if
the value can't be parsed. | oauth2client/contrib/_appengine_ndb.py | def _from_base_type(self, value):
"""Converts our stored JSON string back to the desired type.
Args:
value: A value from the datastore to be converted to the
desired type.
Returns:
A deserialized Credentials (or subclass) object, else None if
... | def _from_base_type(self, value):
"""Converts our stored JSON string back to the desired type.
Args:
value: A value from the datastore to be converted to the
desired type.
Returns:
A deserialized Credentials (or subclass) object, else None if
... | [
"Converts",
"our",
"stored",
"JSON",
"string",
"back",
"to",
"the",
"desired",
"type",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/_appengine_ndb.py#L126-L144 | [
"def",
"_from_base_type",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"None",
"try",
":",
"# Uses the from_json method of the implied class of value",
"credentials",
"=",
"client",
".",
"Credentials",
".",
"new_from_json",
"(",
"value",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _make_flow | Creates a Web Server Flow
Args:
request: A Django request object.
scopes: the request oauth2 scopes.
return_url: The URL to return to after the flow is complete. Defaults
to the path of the current request.
Returns:
An OAuth2 flow object that has been stored in the ... | oauth2client/contrib/django_util/views.py | def _make_flow(request, scopes, return_url=None):
"""Creates a Web Server Flow
Args:
request: A Django request object.
scopes: the request oauth2 scopes.
return_url: The URL to return to after the flow is complete. Defaults
to the path of the current request.
Returns:
... | def _make_flow(request, scopes, return_url=None):
"""Creates a Web Server Flow
Args:
request: A Django request object.
scopes: the request oauth2 scopes.
return_url: The URL to return to after the flow is complete. Defaults
to the path of the current request.
Returns:
... | [
"Creates",
"a",
"Web",
"Server",
"Flow"
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/views.py#L44-L76 | [
"def",
"_make_flow",
"(",
"request",
",",
"scopes",
",",
"return_url",
"=",
"None",
")",
":",
"# Generate a CSRF token to prevent malicious requests.",
"csrf_token",
"=",
"hashlib",
".",
"sha256",
"(",
"os",
".",
"urandom",
"(",
"1024",
")",
")",
".",
"hexdigest... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _get_flow_for_token | Looks up the flow in session to recover information about requested
scopes.
Args:
csrf_token: The token passed in the callback request that should
match the one previously generated and stored in the request on the
initial authorization view.
Returns:
The OAuth2 Flo... | oauth2client/contrib/django_util/views.py | def _get_flow_for_token(csrf_token, request):
""" Looks up the flow in session to recover information about requested
scopes.
Args:
csrf_token: The token passed in the callback request that should
match the one previously generated and stored in the request on the
initial au... | def _get_flow_for_token(csrf_token, request):
""" Looks up the flow in session to recover information about requested
scopes.
Args:
csrf_token: The token passed in the callback request that should
match the one previously generated and stored in the request on the
initial au... | [
"Looks",
"up",
"the",
"flow",
"in",
"session",
"to",
"recover",
"information",
"about",
"requested",
"scopes",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/views.py#L79-L93 | [
"def",
"_get_flow_for_token",
"(",
"csrf_token",
",",
"request",
")",
":",
"flow_pickle",
"=",
"request",
".",
"session",
".",
"get",
"(",
"_FLOW_KEY",
".",
"format",
"(",
"csrf_token",
")",
",",
"None",
")",
"return",
"None",
"if",
"flow_pickle",
"is",
"N... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | oauth2_callback | View that handles the user's return from OAuth2 provider.
This view verifies the CSRF state and OAuth authorization code, and on
success stores the credentials obtained in the storage provider,
and redirects to the return_url specified in the authorize view and
stored in the session.
Args:
... | oauth2client/contrib/django_util/views.py | def oauth2_callback(request):
""" View that handles the user's return from OAuth2 provider.
This view verifies the CSRF state and OAuth authorization code, and on
success stores the credentials obtained in the storage provider,
and redirects to the return_url specified in the authorize view and
sto... | def oauth2_callback(request):
""" View that handles the user's return from OAuth2 provider.
This view verifies the CSRF state and OAuth authorization code, and on
success stores the credentials obtained in the storage provider,
and redirects to the return_url specified in the authorize view and
sto... | [
"View",
"that",
"handles",
"the",
"user",
"s",
"return",
"from",
"OAuth2",
"provider",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/views.py#L96-L156 | [
"def",
"oauth2_callback",
"(",
"request",
")",
":",
"if",
"'error'",
"in",
"request",
".",
"GET",
":",
"reason",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'error_description'",
",",
"request",
".",
"GET",
".",
"get",
"(",
"'error'",
",",
"''",
")",... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | oauth2_authorize | View to start the OAuth2 Authorization flow.
This view starts the OAuth2 authorization flow. If scopes is passed in
as a GET URL parameter, it will authorize those scopes, otherwise the
default scopes specified in settings. The return_url can also be
specified as a GET parameter, otherwise the ref... | oauth2client/contrib/django_util/views.py | def oauth2_authorize(request):
""" View to start the OAuth2 Authorization flow.
This view starts the OAuth2 authorization flow. If scopes is passed in
as a GET URL parameter, it will authorize those scopes, otherwise the
default scopes specified in settings. The return_url can also be
specifie... | def oauth2_authorize(request):
""" View to start the OAuth2 Authorization flow.
This view starts the OAuth2 authorization flow. If scopes is passed in
as a GET URL parameter, it will authorize those scopes, otherwise the
default scopes specified in settings. The return_url can also be
specifie... | [
"View",
"to",
"start",
"the",
"OAuth2",
"Authorization",
"flow",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/views.py#L159-L193 | [
"def",
"oauth2_authorize",
"(",
"request",
")",
":",
"return_url",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'return_url'",
",",
"None",
")",
"if",
"not",
"return_url",
":",
"return_url",
"=",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_REFERER'",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | Storage.locked_get | Retrieve Credential from file.
Returns:
oauth2client.client.Credentials
Raises:
IOError if the file is a symbolic link. | oauth2client/file.py | def locked_get(self):
"""Retrieve Credential from file.
Returns:
oauth2client.client.Credentials
Raises:
IOError if the file is a symbolic link.
"""
credentials = None
_helpers.validate_file(self._filename)
try:
f = open(self.... | def locked_get(self):
"""Retrieve Credential from file.
Returns:
oauth2client.client.Credentials
Raises:
IOError if the file is a symbolic link.
"""
credentials = None
_helpers.validate_file(self._filename)
try:
f = open(self.... | [
"Retrieve",
"Credential",
"from",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/file.py#L35-L59 | [
"def",
"locked_get",
"(",
"self",
")",
":",
"credentials",
"=",
"None",
"_helpers",
".",
"validate_file",
"(",
"self",
".",
"_filename",
")",
"try",
":",
"f",
"=",
"open",
"(",
"self",
".",
"_filename",
",",
"'rb'",
")",
"content",
"=",
"f",
".",
"re... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | Storage._create_file_if_needed | Create an empty file if necessary.
This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created. | oauth2client/file.py | def _create_file_if_needed(self):
"""Create an empty file if necessary.
This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created.
"""
if not os.path.exists(self._filename):
old_umask = os.umask(0o... | def _create_file_if_needed(self):
"""Create an empty file if necessary.
This method will not initialize the file. Instead it implements a
simple version of "touch" to ensure the file has been created.
"""
if not os.path.exists(self._filename):
old_umask = os.umask(0o... | [
"Create",
"an",
"empty",
"file",
"if",
"necessary",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/file.py#L61-L72 | [
"def",
"_create_file_if_needed",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_filename",
")",
":",
"old_umask",
"=",
"os",
".",
"umask",
"(",
"0o177",
")",
"try",
":",
"open",
"(",
"self",
".",
"_filename"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | Storage.locked_put | Write Credentials to file.
Args:
credentials: Credentials, the credentials to store.
Raises:
IOError if the file is a symbolic link. | oauth2client/file.py | def locked_put(self, credentials):
"""Write Credentials to file.
Args:
credentials: Credentials, the credentials to store.
Raises:
IOError if the file is a symbolic link.
"""
self._create_file_if_needed()
_helpers.validate_file(self._filename)
... | def locked_put(self, credentials):
"""Write Credentials to file.
Args:
credentials: Credentials, the credentials to store.
Raises:
IOError if the file is a symbolic link.
"""
self._create_file_if_needed()
_helpers.validate_file(self._filename)
... | [
"Write",
"Credentials",
"to",
"file",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/file.py#L74-L87 | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"self",
".",
"_create_file_if_needed",
"(",
")",
"_helpers",
".",
"validate_file",
"(",
"self",
".",
"_filename",
")",
"f",
"=",
"open",
"(",
"self",
".",
"_filename",
",",
"'w'",
")",
"f",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | CredentialsField.to_python | Overrides ``models.Field`` method. This is used to convert
bytes (from serialization etc) to an instance of this class | oauth2client/contrib/django_util/models.py | def to_python(self, value):
"""Overrides ``models.Field`` method. This is used to convert
bytes (from serialization etc) to an instance of this class"""
if value is None:
return None
elif isinstance(value, oauth2client.client.Credentials):
return value
els... | def to_python(self, value):
"""Overrides ``models.Field`` method. This is used to convert
bytes (from serialization etc) to an instance of this class"""
if value is None:
return None
elif isinstance(value, oauth2client.client.Credentials):
return value
els... | [
"Overrides",
"models",
".",
"Field",
"method",
".",
"This",
"is",
"used",
"to",
"convert",
"bytes",
"(",
"from",
"serialization",
"etc",
")",
"to",
"an",
"instance",
"of",
"this",
"class"
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/models.py#L44-L57 | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"value",
",",
"oauth2client",
".",
"client",
".",
"Credentials",
")",
":",
"return",
"value",
"else",
":",
"try",
":... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | CredentialsField.get_prep_value | Overrides ``models.Field`` method. This is used to convert
the value from an instances of this class to bytes that can be
inserted into the database. | oauth2client/contrib/django_util/models.py | def get_prep_value(self, value):
"""Overrides ``models.Field`` method. This is used to convert
the value from an instances of this class to bytes that can be
inserted into the database.
"""
if value is None:
return None
else:
return encoding.smart_... | def get_prep_value(self, value):
"""Overrides ``models.Field`` method. This is used to convert
the value from an instances of this class to bytes that can be
inserted into the database.
"""
if value is None:
return None
else:
return encoding.smart_... | [
"Overrides",
"models",
".",
"Field",
"method",
".",
"This",
"is",
"used",
"to",
"convert",
"the",
"value",
"from",
"an",
"instances",
"of",
"this",
"class",
"to",
"bytes",
"that",
"can",
"be",
"inserted",
"into",
"the",
"database",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/models.py#L59-L68 | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return",
"encoding",
".",
"smart_text",
"(",
"base64",
".",
"b64encode",
"(",
"jsonpickle",
".",
"encode",
"(",
"value",
")",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | CredentialsField.value_to_string | Convert the field value from the provided model to a string.
Used during model serialization.
Args:
obj: db.Model, model object
Returns:
string, the serialized field value | oauth2client/contrib/django_util/models.py | def value_to_string(self, obj):
"""Convert the field value from the provided model to a string.
Used during model serialization.
Args:
obj: db.Model, model object
Returns:
string, the serialized field value
"""
value = self._get_val_from_obj(obj... | def value_to_string(self, obj):
"""Convert the field value from the provided model to a string.
Used during model serialization.
Args:
obj: db.Model, model object
Returns:
string, the serialized field value
"""
value = self._get_val_from_obj(obj... | [
"Convert",
"the",
"field",
"value",
"from",
"the",
"provided",
"model",
"to",
"a",
"string",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/django_util/models.py#L70-L82 | [
"def",
"value_to_string",
"(",
"self",
",",
"obj",
")",
":",
"value",
"=",
"self",
".",
"_get_val_from_obj",
"(",
"obj",
")",
"return",
"self",
".",
"get_prep_value",
"(",
"value",
")"
] | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | make_signed_jwt | Make a signed JWT.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
signer: crypt.Signer, Cryptographic signer.
payload: dict, Dictionary of data to convert to JSON and then sign.
key_id: string, (Optional) Key ID header.
Returns:
string, The JWT for... | oauth2client/crypt.py | def make_signed_jwt(signer, payload, key_id=None):
"""Make a signed JWT.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
signer: crypt.Signer, Cryptographic signer.
payload: dict, Dictionary of data to convert to JSON and then sign.
key_id: string, (Optional... | def make_signed_jwt(signer, payload, key_id=None):
"""Make a signed JWT.
See http://self-issued.info/docs/draft-jones-json-web-token.html.
Args:
signer: crypt.Signer, Cryptographic signer.
payload: dict, Dictionary of data to convert to JSON and then sign.
key_id: string, (Optional... | [
"Make",
"a",
"signed",
"JWT",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/crypt.py#L74-L102 | [
"def",
"make_signed_jwt",
"(",
"signer",
",",
"payload",
",",
"key_id",
"=",
"None",
")",
":",
"header",
"=",
"{",
"'typ'",
":",
"'JWT'",
",",
"'alg'",
":",
"'RS256'",
"}",
"if",
"key_id",
"is",
"not",
"None",
":",
"header",
"[",
"'kid'",
"]",
"=",
... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
valid | _verify_signature | Verifies signed content using a list of certificates.
Args:
message: string or bytes, The message to verify.
signature: string or bytes, The signature on the message.
certs: iterable, certificates in PEM format.
Raises:
AppIdentityError: If none of the certificates can verify t... | oauth2client/crypt.py | def _verify_signature(message, signature, certs):
"""Verifies signed content using a list of certificates.
Args:
message: string or bytes, The message to verify.
signature: string or bytes, The signature on the message.
certs: iterable, certificates in PEM format.
Raises:
A... | def _verify_signature(message, signature, certs):
"""Verifies signed content using a list of certificates.
Args:
message: string or bytes, The message to verify.
signature: string or bytes, The signature on the message.
certs: iterable, certificates in PEM format.
Raises:
A... | [
"Verifies",
"signed",
"content",
"using",
"a",
"list",
"of",
"certificates",
"."
] | googleapis/oauth2client | python | https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/crypt.py#L105-L123 | [
"def",
"_verify_signature",
"(",
"message",
",",
"signature",
",",
"certs",
")",
":",
"for",
"pem",
"in",
"certs",
":",
"verifier",
"=",
"Verifier",
".",
"from_string",
"(",
"pem",
",",
"is_x509_cert",
"=",
"True",
")",
"if",
"verifier",
".",
"verify",
"... | 50d20532a748f18e53f7d24ccbe6647132c979a9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.