_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q32300
crypto_core_ed25519_add
train
def crypto_core_ed25519_add(p, q): """ Add two points on the edwards25519 curve. :param p: a :py:data:`.crypto_core_ed25519_BYTES` long bytes sequence representing a point on the edwards25519 curve :type p: bytes :param q: a :py:data:`.crypto_core_ed25519_BYTES` long bytes sequence ...
python
{ "resource": "" }
q32301
crypto_box_keypair
train
def crypto_box_keypair(): """ Returns a randomly generated public and secret key. :rtype: (bytes(public_key), bytes(secret_key)) """ pk = ffi.new("unsigned char[]", crypto_box_PUBLICKEYBYTES) sk = ffi.new("unsigned char[]", crypto_box_SECRETKEYBYTES) rc = lib.crypto_box_keypair(pk, sk) ...
python
{ "resource": "" }
q32302
crypto_box
train
def crypto_box(message, nonce, pk, sk): """ Encrypts and returns a message ``message`` using the secret key ``sk``, public key ``pk``, and the nonce ``nonce``. :param message: bytes :param nonce: bytes :param pk: bytes :param sk: bytes :rtype: bytes """ if len(nonce) != crypto_b...
python
{ "resource": "" }
q32303
crypto_box_open
train
def crypto_box_open(ciphertext, nonce, pk, sk): """ Decrypts and returns an encrypted message ``ciphertext``, using the secret key ``sk``, public key ``pk``, and the nonce ``nonce``. :param ciphertext: bytes :param nonce: bytes :param pk: bytes :param sk: bytes :rtype: bytes """ ...
python
{ "resource": "" }
q32304
crypto_box_beforenm
train
def crypto_box_beforenm(pk, sk): """ Computes and returns the shared key for the public key ``pk`` and the secret key ``sk``. This can be used to speed up operations where the same set of keys is going to be used multiple times. :param pk: bytes :param sk: bytes :rtype: bytes """ if...
python
{ "resource": "" }
q32305
crypto_box_afternm
train
def crypto_box_afternm(message, nonce, k): """ Encrypts and returns the message ``message`` using the shared key ``k`` and the nonce ``nonce``. :param message: bytes :param nonce: bytes :param k: bytes :rtype: bytes """ if len(nonce) != crypto_box_NONCEBYTES: raise exc.Value...
python
{ "resource": "" }
q32306
crypto_box_open_afternm
train
def crypto_box_open_afternm(ciphertext, nonce, k): """ Decrypts and returns the encrypted message ``ciphertext``, using the shared key ``k`` and the nonce ``nonce``. :param ciphertext: bytes :param nonce: bytes :param k: bytes :rtype: bytes """ if len(nonce) != crypto_box_NONCEBYTES...
python
{ "resource": "" }
q32307
crypto_box_seal
train
def crypto_box_seal(message, pk): """ Encrypts and returns a message ``message`` using an ephemeral secret key and the public key ``pk``. The ephemeral public key, which is embedded in the sealed box, is also used, in combination with ``pk``, to derive the nonce needed for the underlying box con...
python
{ "resource": "" }
q32308
crypto_box_seal_open
train
def crypto_box_seal_open(ciphertext, pk, sk): """ Decrypts and returns an encrypted message ``ciphertext``, using the recipent's secret key ``sk`` and the sender's ephemeral public key embedded in the sealed box. The box contruct nonce is derived from the recipient's public key ``pk`` and the sender...
python
{ "resource": "" }
q32309
sodium_memcmp
train
def sodium_memcmp(inp1, inp2): """ Compare contents of two memory regions in constant time """ ensure(isinstance(inp1, bytes), raising=exc.TypeError) ensure(isinstance(inp2, bytes), raising=exc.TypeError) ln = max(len(inp1), len(inp2)) buf1 = ffi.new("char []", ln) ...
python
{ "resource": "" }
q32310
sodium_increment
train
def sodium_increment(inp): """ Increment the value of a byte-sequence interpreted as the little-endian representation of a unsigned big integer. :param inp: input bytes buffer :type inp: bytes :return: a byte-sequence representing, as a little-endian
python
{ "resource": "" }
q32311
Definition.error_lineno
train
def error_lineno(self): """Get the line number with which to report violations."""
python
{ "resource": "" }
q32312
Definition.source
train
def source(self): """Return the source code for the definition.""" full_src = self._source[self._slice] def is_empty_or_comment(line): return line.strip() == '' or line.strip().startswith('#')
python
{ "resource": "" }
q32313
Function.is_public
train
def is_public(self): """Return True iff this function should be considered public.""" if self.dunder_all is not None:
python
{ "resource": "" }
q32314
Parser.parse
train
def parse(self, filelike, filename): """Parse the given file-like object and return its Module object.""" self.log = log self.source = filelike.readlines() src = ''.join(self.source) try: compile(src, filename, 'exec') except SyntaxError as error: ...
python
{ "resource": "" }
q32315
Parser.consume
train
def consume(self, kind): """Consume one token and verify it is of the expected kind.""" next_token = self.stream.move() if next_token.kind !=
python
{ "resource": "" }
q32316
Parser.parse_definition
train
def parse_definition(self, class_): """Parse a definition and return its value in a `class_` object.""" start = self.line self.consume(tk.NAME) name = self.current.value self.log.debug("parsing %s '%s'", class_.__name__, name) self.stream.move() if self.current.ki...
python
{ "resource": "" }
q32317
Parser.parse_skip_comment
train
def parse_skip_comment(self): """Parse a definition comment for noqa skips.""" skipped_error_codes = '' if self.current.kind == tk.COMMENT: if 'noqa: ' in self.current.value: skipped_error_codes = ''.join(
python
{ "resource": "" }
q32318
Parser._parse_from_import_source
train
def _parse_from_import_source(self): """Parse the 'from x import' part in a 'from x import y' statement. Return true iff `x` is __future__. """ assert self.current.value == 'from', self.current.value self.stream.move() is_future_import = self.current.value == '__future__...
python
{ "resource": "" }
q32319
setup_stream_handlers
train
def setup_stream_handlers(conf): """Setup logging stream handlers according to the options.""" class StdoutFilter(logging.Filter): def filter(self, record): return record.levelno in (logging.DEBUG, logging.INFO) log.handlers = [] stdout_handler = logging.StreamHandler(sys.stdout) ...
python
{ "resource": "" }
q32320
check
train
def check(filenames, select=None, ignore=None, ignore_decorators=None): """Generate docstring errors that exist in `filenames` iterable. By default, the PEP-257 convention is checked. To specifically define the set of error codes to check for, supply either `select` or `ignore` (but not both). In eithe...
python
{ "resource": "" }
q32321
ConventionChecker._get_docstring_indent
train
def _get_docstring_indent(definition, docstring): """Return the indentation of the docstring's opening quotes."""
python
{ "resource": "" }
q32322
ConventionChecker._get_leading_words
train
def _get_leading_words(line): """Return any leading set of words from `line`. For example, if `line` is " Hello world!!!", returns "Hello world". """
python
{ "resource": "" }
q32323
ConventionChecker._is_a_docstring_section
train
def _is_a_docstring_section(context): """Check if the suspected context is really a section header. Lets have a look at the following example docstring: '''Title. Some part of the docstring that specifies what the function returns. <----- Not a real section name. It...
python
{ "resource": "" }
q32324
Error.set_context
train
def set_context(self, definition: Definition, explanation: str) -> None: """Set the
python
{ "resource": "" }
q32325
Error.message
train
def message(self) -> str: """Return the message to print to the user.""" ret = '{}: {}'.format(self.code, self.short_desc) if self.context is not None:
python
{ "resource": "" }
q32326
Error.lines
train
def lines(self) -> str: """Return the source code lines for this error.""" if self.definition is None: return '' source = '' lines = self.definition.source offset = self.definition.start # type: ignore lines_stripped = list(reversed(list(dropwhile(is_blank, ...
python
{ "resource": "" }
q32327
ErrorRegistry.create_group
train
def create_group(cls, prefix: str, name: str) -> ErrorGroup: """Create a new error group and return it."""
python
{ "resource": "" }
q32328
ErrorRegistry.get_error_codes
train
def get_error_codes(cls) -> Iterable[str]: """Yield all registered codes.""" for group in cls.groups:
python
{ "resource": "" }
q32329
ErrorRegistry.to_rst
train
def to_rst(cls) -> str: """Output the registry as reStructuredText, for documentation.""" sep_line = '+' + 6 * '-' + '+' + '-' * 71 + '+\n' blank_line = '|' + 78 * ' ' + '|\n' table = '' for group in cls.groups: table += sep_line table += blank_line ...
python
{ "resource": "" }
q32330
check_initialized
train
def check_initialized(method): """Check that the configuration object was initialized.""" def _decorator(self, *args, **kwargs): if self._arguments is None or self._options is None:
python
{ "resource": "" }
q32331
ConfigurationParser.parse
train
def parse(self): """Parse the configuration. If one of `BASE_ERROR_SELECTION_OPTIONS` was selected, overrides all error codes to check and disregards any error code related configurations from the configuration files. """ self._options, self._arguments = self._parse_arg...
python
{ "resource": "" }
q32332
ConfigurationParser.get_files_to_check
train
def get_files_to_check(self): """Generate files and error codes to check on each one. Walk dir trees under `self._arguments` and yield file names that `match` under each directory that `match_dir`. The method locates the configuration for each file name and yields a tuple of (fi...
python
{ "resource": "" }
q32333
ConfigurationParser._get_config_by_discovery
train
def _get_config_by_discovery(self, node): """Get a configuration for checking `node` by config discovery. Config discovery happens when no explicit config file is specified. The file system is searched for config files starting from the directory containing the file being checke...
python
{ "resource": "" }
q32334
ConfigurationParser._get_config
train
def _get_config(self, node): """Get and cache the run configuration for `node`. If no configuration exists (not local and not for the parent node), returns and caches a default configuration. The algorithm: ------------- * If the current directory's configuration exists...
python
{ "resource": "" }
q32335
ConfigurationParser._get_node_dir
train
def _get_node_dir(node): """Return the absolute path of the directory of a filesystem node.""" path = os.path.abspath(node)
python
{ "resource": "" }
q32336
ConfigurationParser._read_configuration_file
train
def _read_configuration_file(self, path): """Try to read and parse `path` as a configuration file. If the configurations were illegal (checked with `self._validate_options`), raises `IllegalConfiguration`. Returns (options, should_inherit). """ parser = RawConfigParser...
python
{ "resource": "" }
q32337
ConfigurationParser._merge_configuration
train
def _merge_configuration(self, parent_config, child_options): """Merge parent config into the child options. The migration process requires an `options` object for the child in order to distinguish between mutually exclusive codes, add-select and add-ignore error codes. """ ...
python
{ "resource": "" }
q32338
ConfigurationParser._parse_args
train
def _parse_args(self, args=None, values=None): """Parse the options using `self._parser` and reformat the options."""
python
{ "resource": "" }
q32339
ConfigurationParser._create_run_config
train
def _create_run_config(options): """Create a `RunConfiguration` object from `options`."""
python
{ "resource": "" }
q32340
ConfigurationParser._create_check_config
train
def _create_check_config(cls, options, use_defaults=True): """Create a `CheckConfiguration` object from `options`. If `use_defaults`, any of the match options that are `None` will be replaced with their default value and the default convention will be set for the checked codes. ...
python
{ "resource": "" }
q32341
ConfigurationParser._get_section_name
train
def _get_section_name(cls, parser): """Parse options from relevant section.""" for section_name in
python
{ "resource": "" }
q32342
ConfigurationParser._get_config_file_in_folder
train
def _get_config_file_in_folder(cls, path): """Look for a configuration file in `path`. If exists return its full path, otherwise None. """ if os.path.isfile(path): path = os.path.dirname(path) for fn in cls.PROJECT_CONFIG_FILES:
python
{ "resource": "" }
q32343
ConfigurationParser._get_exclusive_error_codes
train
def _get_exclusive_error_codes(cls, options): """Extract the error codes from the selected exclusive option.""" codes = set(ErrorRegistry.get_error_codes()) checked_codes = None if options.ignore is not None: ignored = cls._expand_error_codes(options.ignore) chec...
python
{ "resource": "" }
q32344
ConfigurationParser._set_add_options
train
def _set_add_options(cls, checked_codes, options): """Set `checked_codes` by the `add_ignore` or `add_select` options."""
python
{ "resource": "" }
q32345
ConfigurationParser._expand_error_codes
train
def _expand_error_codes(code_parts): """Return an expanded set of error codes to ignore.""" codes = set(ErrorRegistry.get_error_codes()) expanded_codes = set() try: for part in code_parts: # Dealing with split-lined configurations; The part might begin ...
python
{ "resource": "" }
q32346
ConfigurationParser._get_checked_errors
train
def _get_checked_errors(cls, options): """Extract the codes needed to be checked from `options`.""" checked_codes = cls._get_exclusive_error_codes(options) if checked_codes is None:
python
{ "resource": "" }
q32347
ConfigurationParser._validate_options
train
def _validate_options(cls, options): """Validate the mutually exclusive options. Return `True` iff only zero or one of `BASE_ERROR_SELECTION_OPTIONS` was selected. """ for opt1, opt2 in \ itertools.permutations(cls.BASE_ERROR_SELECTION_OPTIONS, 2): i...
python
{ "resource": "" }
q32348
ConfigurationParser._has_exclusive_option
train
def _has_exclusive_option(cls, options): """Return `True` iff one or more exclusive options were selected."""
python
{ "resource": "" }
q32349
pairwise
train
def pairwise( iterable: Iterable, default_value: Any, ) -> Iterable[Tuple[Any, Any]]: """Return pairs of items from `iterable`. pairwise([1, 2, 3], default_value=None) -> (1, 2) (2, 3), (3, None)
python
{ "resource": "" }
q32350
load_wordlist
train
def load_wordlist(name: str) -> Iterator[str]: """Iterate over lines of a wordlist data file. `name` should be the name of a package data file within the data/ directory. Whitespace and #-prefixed comments are stripped from each line. """ data = pkgutil.get_data('pydocstyle', 'data/' + name) ...
python
{ "resource": "" }
q32351
EvolutionaryAlgorithmSearchCV.possible_params
train
def possible_params(self): """ Used when assuming params is
python
{ "resource": "" }
q32352
AuthorizedHttp.urlopen
train
def urlopen(self, method, url, body=None, headers=None, **kwargs): """Implementation of urllib3's urlopen.""" # pylint: disable=arguments-differ # We use kwargs to collect additional args that we don't need to # introspect here. However, we do explicitly collect the two # positio...
python
{ "resource": "" }
q32353
Credentials.service_account_email
train
def service_account_email(self): """The service account email.""" if self._service_account_id is
python
{ "resource": "" }
q32354
convert
train
def convert(credentials): """Convert oauth2client credentials to google-auth credentials. This class converts: - :class:`oauth2client.client.OAuth2Credentials` to :class:`google.oauth2.credentials.Credentials`. - :class:`oauth2client.client.GoogleCredentials` to :class:`google.oauth2.crede...
python
{ "resource": "" }
q32355
Credentials._update_token
train
def _update_token(self, request): """Updates credentials with a new access_token representing the impersonated account. Args: request (google.auth.transport.requests.Request): Request object to use for refreshing credentials. """ # Refresh our source...
python
{ "resource": "" }
q32356
verify_signature
train
def verify_signature(message, signature, certs): """Verify an RSA cryptographic signature. Checks that the provided ``signature`` was generated from ``bytes`` using the private key associated with the ``cert``. Args: message (Union[str, bytes]): The plaintext message. signature (Union[...
python
{ "resource": "" }
q32357
Signer._make_signing_request
train
def _make_signing_request(self, message): """Makes a request to the API signBlob API.""" message = _helpers.to_bytes(message) method = 'POST' url = _SIGN_BLOB_URI.format(self._service_account_email) headers = {} body = json.dumps({ 'bytesToSign': base64.b64en...
python
{ "resource": "" }
q32358
_fetch_certs
train
def _fetch_certs(request, certs_url): """Fetches certificates. Google-style cerificate endpoints return JSON in the format of ``{'key id': 'x509 certificate'}``. Args: request (google.auth.transport.Request): The object used to make HTTP requests.
python
{ "resource": "" }
q32359
verify_token
train
def verify_token(id_token, request, audience=None, certs_url=_GOOGLE_OAUTH2_CERTS_URL): """Verifies an ID token and returns the decoded token. Args: id_token (Union[str, bytes]): The encoded token. request (google.auth.transport.Request): The object used to make HTT...
python
{ "resource": "" }
q32360
verify_oauth2_token
train
def verify_oauth2_token(id_token, request, audience=None): """Verifies an ID Token issued by Google's OAuth 2.0 authorization server. Args: id_token (Union[str, bytes]): The encoded token. request (google.auth.transport.Request): The object used to make
python
{ "resource": "" }
q32361
verify_firebase_token
train
def verify_firebase_token(id_token, request, audience=None): """Verifies an ID Token issued by Firebase Authentication. Args: id_token (Union[str, bytes]): The encoded token. request (google.auth.transport.Request): The object used to make
python
{ "resource": "" }
q32362
_decode_jwt_segment
train
def _decode_jwt_segment(encoded_section): """Decodes a single JWT segment.""" section_bytes = _helpers.padded_urlsafe_b64decode(encoded_section)
python
{ "resource": "" }
q32363
_unverified_decode
train
def _unverified_decode(token): """Decodes a token and does no verification. Args: token (Union[str, bytes]): The encoded JWT. Returns: Tuple[str, str, str, str]: header, payload, signed_section, and signature. Raises: ValueError: if there are an incorrect amount of...
python
{ "resource": "" }
q32364
decode
train
def decode(token, certs=None, verify=True, audience=None): """Decode and verify a JWT. Args: token (str): The encoded JWT. certs (Union[str, bytes, Mapping[str, Union[str, bytes]]]): The certificate used to validate the JWT signature. If bytes or string, it must the the ...
python
{ "resource": "" }
q32365
OnDemandCredentials._get_jwt_for_audience
train
def _get_jwt_for_audience(self, audience): """Get a JWT For a given audience. If there is already an existing, non-expired token in the cache for the audience, that token is used. Otherwise, a new token will be created. Args: audience (str): The intended audience. ...
python
{ "resource": "" }
q32366
OnDemandCredentials.before_request
train
def before_request(self, request, method, url, headers): """Performs credential-specific before request logic. Args: request (Any): Unused. JWT credentials do not need to make an HTTP request to refresh. method (str): The request's HTTP method. url (s...
python
{ "resource": "" }
q32367
RSAVerifier.from_string
train
def from_string(cls, public_key): """Construct an Verifier instance from a public key or public certificate string. Args: public_key (Union[str, bytes]): The public key in PEM format or the x509 public key certificate. Returns: Verifier: The cons...
python
{ "resource": "" }
q32368
RSASigner.from_string
train
def from_string(cls, key, key_id=None): """Construct a RSASigner from a private key in PEM format. Args: key (Union[bytes, str]): Private key in PEM format. key_id (str): An optional key id used to identify the private key. Returns: google.auth.crypt._crypto...
python
{ "resource": "" }
q32369
_warn_about_problematic_credentials
train
def _warn_about_problematic_credentials(credentials): """Determines if the credentials are problematic. Credentials from the Cloud SDK that are associated with Cloud SDK's project are problematic because they may not have APIs enabled and have limited quota. If this is the case, warn about it. """ ...
python
{ "resource": "" }
q32370
_load_credentials_from_file
train
def _load_credentials_from_file(filename): """Loads credentials from a file. The credentials file must be a service account key or stored authorized user credentials. Args: filename (str): The full path to the credentials file. Returns: Tuple[google.auth.credentials.Credentials, O...
python
{ "resource": "" }
q32371
_get_gcloud_sdk_credentials
train
def _get_gcloud_sdk_credentials(): """Gets the credentials and project ID from the Cloud SDK.""" from google.auth import _cloud_sdk # Check if application default credentials exist. credentials_filename = (
python
{ "resource": "" }
q32372
_get_explicit_environ_credentials
train
def _get_explicit_environ_credentials(): """Gets credentials from the GOOGLE_APPLICATION_CREDENTIALS environment variable.""" explicit_file = os.environ.get(environment_vars.CREDENTIALS) if explicit_file is not None:
python
{ "resource": "" }
q32373
_get_gae_credentials
train
def _get_gae_credentials(): """Gets Google App Engine App Identity credentials and project ID.""" # While this library is normally bundled with app_engine, there are # some cases where it's not available, so we tolerate ImportError. try: import google.auth.app_engine as app_engine except Imp...
python
{ "resource": "" }
q32374
_get_gce_credentials
train
def _get_gce_credentials(request=None): """Gets credentials and project ID from the GCE Metadata Service.""" # Ping requires a transport, but we want application default credentials # to require no arguments. So, we'll use the _http_client transport which # uses http.client. This is only acceptable beca...
python
{ "resource": "" }
q32375
default
train
def default(scopes=None, request=None): """Gets the default credentials for the current environment. `Application Default Credentials`_ provides an easy way to obtain credentials to call Google APIs for server-to-server or local applications. This function acquires credentials from the environment in t...
python
{ "resource": "" }
q32376
AuthMetadataPlugin._get_authorization_headers
train
def _get_authorization_headers(self, context): """Gets the authorization headers for a request. Returns: Sequence[Tuple[str, str]]: A list of request headers (key, value)
python
{ "resource": "" }
q32377
Credentials.from_service_account_info
train
def from_service_account_info(cls, info, **kwargs): """Creates a Credentials instance from parsed service account info. Args: info (Mapping[str, str]): The service account info in Google format. kwargs: Additional arguments to pass to the constructor. Re...
python
{ "resource": "" }
q32378
Credentials.from_service_account_file
train
def from_service_account_file(cls, filename, **kwargs): """Creates a Credentials instance from a service account json file. Args: filename (str): The path to the service account json file. kwargs: Additional arguments to pass to
python
{ "resource": "" }
q32379
Credentials.with_subject
train
def with_subject(self, subject): """Create a copy of these credentials with the specified subject. Args: subject (str): The subject claim. Returns: google.auth.service_account.Credentials: A new credentials instance. """ return self.__cla...
python
{ "resource": "" }
q32380
IDTokenCredentials.with_target_audience
train
def with_target_audience(self, target_audience): """Create a copy of these credentials with the specified target audience. Args: target_audience (str): The intended audience for these credentials, used when requesting the ID Token. Returns: google.au...
python
{ "resource": "" }
q32381
AuthorizedSession.request
train
def request(self, method, url, data=None, headers=None, **kwargs): """Implementation of Requests' request.""" # pylint: disable=arguments-differ # Requests has a ton of arguments to request, but only two # (method, url) are required. We pass through all of the other # arguments t...
python
{ "resource": "" }
q32382
with_scopes_if_required
train
def with_scopes_if_required(credentials, scopes): """Creates a copy of the credentials with scopes if scoping is required. This helper function is useful when you do not know (or care to know) the specific type of credentials you are using (such as when you use :func:`google.auth.default`). This functi...
python
{ "resource": "" }
q32383
_bit_list_to_bytes
train
def _bit_list_to_bytes(bit_list): """Converts an iterable of 1s and 0s to bytes. Combines the list 8 at a time, treating each group of 8 bits as a single byte. Args: bit_list (Sequence): Sequence of 1s and 0s. Returns: bytes: The decoded bytes. """ num_bits = len(bit_list)...
python
{ "resource": "" }
q32384
RSASigner.from_string
train
def from_string(cls, key, key_id=None): """Construct an Signer instance from a private key in PEM format. Args: key (str): Private key in PEM format. key_id (str): An optional key id used to identify the private key. Returns: google.auth.crypt.Signer: The co...
python
{ "resource": "" }
q32385
_handle_error_response
train
def _handle_error_response(response_body): """"Translates an error response into an exception. Args: response_body (str): The decoded response data. Raises: google.auth.exceptions.RefreshError """ try: error_data = json.loads(response_body) error_details = '{}: {}'....
python
{ "resource": "" }
q32386
_parse_expiry
train
def _parse_expiry(response_data): """Parses the expiry field from a response into a datetime. Args: response_data (Mapping): The JSON-parsed response data. Returns: Optional[datetime]: The expiration
python
{ "resource": "" }
q32387
_token_endpoint_request
train
def _token_endpoint_request(request, token_uri, body): """Makes a request to the OAuth 2.0 authorization server's token endpoint. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. token_uri (str): The OAuth 2.0 authorizations server's token endpoi...
python
{ "resource": "" }
q32388
jwt_grant
train
def jwt_grant(request, token_uri, assertion): """Implements the JWT Profile for OAuth 2.0 Authorization Grants. For more details, see `rfc7523 section 4`_. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. token_uri (str): The OAuth 2.0 autho...
python
{ "resource": "" }
q32389
id_token_jwt_grant
train
def id_token_jwt_grant(request, token_uri, assertion): """Implements the JWT Profile for OAuth 2.0 Authorization Grants, but requests an OpenID Connect ID Token instead of an access token. This is a variant on the standard JWT Profile that is currently unique to Google. This was added for the benefit o...
python
{ "resource": "" }
q32390
refresh_grant
train
def refresh_grant(request, token_uri, refresh_token, client_id, client_secret): """Implements the OAuth 2.0 refresh token grant. For more details, see `rfc678 section 6`_. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. token_uri (str): The...
python
{ "resource": "" }
q32391
get_config_path
train
def get_config_path(): """Returns the absolute path the the Cloud SDK's configuration directory. Returns: str: The Cloud SDK config path. """ # If the path is explicitly set, return that. try: return os.environ[environment_vars.CLOUD_SDK_CONFIG_DIR] except KeyError: pass...
python
{ "resource": "" }
q32392
get_project_id
train
def get_project_id(): """Gets the project ID from the Cloud SDK. Returns: Optional[str]: The project ID. """ if os.name == 'nt': command = _CLOUD_SDK_WINDOWS_COMMAND else: command = _CLOUD_SDK_POSIX_COMMAND try: output = subprocess.check_output( (com...
python
{ "resource": "" }
q32393
Credentials._retrieve_info
train
def _retrieve_info(self, request): """Retrieve information about the service account. Updates the scopes and retrieves the full service account email. Args: request (google.auth.transport.Request): The object used to make HTTP requests. """
python
{ "resource": "" }
q32394
Credentials.refresh
train
def refresh(self, request): """Refresh the access token and scopes. Args: request (google.auth.transport.Request): The object used to make HTTP requests. Raises: google.auth.exceptions.RefreshError: If the Compute Engine metadata service ...
python
{ "resource": "" }
q32395
Credentials.from_authorized_user_info
train
def from_authorized_user_info(cls, info, scopes=None): """Creates a Credentials instance from parsed authorized user info. Args: info (Mapping[str, str]): The authorized user info in Google format. scopes (Sequence[str]): Optional list of scopes to include in the...
python
{ "resource": "" }
q32396
Credentials.from_authorized_user_file
train
def from_authorized_user_file(cls, filename, scopes=None): """Creates a Credentials instance from an authorized user json file. Args: filename (str): The path to the authorized user json file. scopes (Sequence[str]): Optional list of scopes to include in the cred...
python
{ "resource": "" }
q32397
ping
train
def ping(request, timeout=_METADATA_DEFAULT_TIMEOUT, retry_count=3): """Checks to see if the metadata server is available. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. timeout (int): How long to wait for the metadata server to respond. ...
python
{ "resource": "" }
q32398
get
train
def get(request, path, root=_METADATA_ROOT, recursive=False): """Fetch a resource from the metadata server. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. path (str): The resource to retrieve. For example, ``'instance/service-accoun...
python
{ "resource": "" }
q32399
get_service_account_token
train
def get_service_account_token(request, service_account='default'): """Get the OAuth 2.0 access token for a service account. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. service_account (str): The string 'default' or a service account email ...
python
{ "resource": "" }