@@ -557,128 +557,3 @@ def sign_jwt(
557557 return self ._inner_api_calls ["sign_jwt" ](
558558 request , retry = retry , timeout = timeout , metadata = metadata
559559 )
560-
561- def generate_identity_binding_access_token (
562- self ,
563- name ,
564- scope ,
565- jwt ,
566- retry = google .api_core .gapic_v1 .method .DEFAULT ,
567- timeout = google .api_core .gapic_v1 .method .DEFAULT ,
568- metadata = None ,
569- ):
570- """
571- Exchange a JWT signed by third party identity provider to an OAuth 2.0
572- access token
573-
574- Example:
575- >>> from google.cloud import iam_credentials_v1
576- >>>
577- >>> client = iam_credentials_v1.IAMCredentialsClient()
578- >>>
579- >>> name = client.service_account_path('[PROJECT]', '[SERVICE_ACCOUNT]')
580- >>>
581- >>> # TODO: Initialize `scope`:
582- >>> scope = []
583- >>>
584- >>> # TODO: Initialize `jwt`:
585- >>> jwt = ''
586- >>>
587- >>> response = client.generate_identity_binding_access_token(name, scope, jwt)
588-
589- Args:
590- name (str): The resource name of the service account for which the credentials are
591- requested, in the following format:
592- ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``.
593- scope (list[str]): Code to identify the scopes to be included in the OAuth 2.0 access token.
594- See https://developers.google.com/identity/protocols/googlescopes for more
595- information.
596- At least one value required.
597- jwt (str): Required. Input token. Must be in JWT format according to RFC7523
598- (https://tools.ietf.org/html/rfc7523) and must have 'kid' field in the
599- header. Supported signing algorithms: RS256 (RS512, ES256, ES512 coming
600- soon). Mandatory payload fields (along the lines of RFC 7523, section
601- 3):
602-
603- - iss: issuer of the token. Must provide a discovery document at
604- $iss/.well-known/openid-configuration . The document needs to be
605- formatted according to section 4.2 of the OpenID Connect Discovery
606- 1.0 specification.
607- - iat: Issue time in seconds since epoch. Must be in the past.
608- - exp: Expiration time in seconds since epoch. Must be less than 48
609- hours after iat. We recommend to create tokens that last shorter than
610- 6 hours to improve security unless business reasons mandate longer
611- expiration times. Shorter token lifetimes are generally more secure
612- since tokens that have been exfiltrated by attackers can be used for
613- a shorter time. you can configure the maximum lifetime of the
614- incoming token in the configuration of the mapper. The resulting
615- Google token will expire within an hour or at "exp", whichever is
616- earlier.
617- - sub: JWT subject, identity asserted in the JWT.
618- - aud: Configured in the mapper policy. By default the service account
619- email.
620-
621- Claims from the incoming token can be transferred into the output token
622- accoding to the mapper configuration. The outgoing claim size is
623- limited. Outgoing claims size must be less than 4kB serialized as JSON
624- without whitespace.
625-
626- Example header: { "alg": "RS256", "kid":
627- "92a4265e14ab04d4d228a48d10d4ca31610936f8" } Example payload: { "iss":
628- "https://accounts.google.com", "iat": 1517963104, "exp": 1517966704,
629- "aud": "https://iamcredentials.googleapis.com/", "sub":
630- "113475438248934895348", "my\_claims": { "additional\_claim": "value" }
631- }
632- retry (Optional[google.api_core.retry.Retry]): A retry object used
633- to retry requests. If ``None`` is specified, requests will not
634- be retried.
635- timeout (Optional[float]): The amount of time, in seconds, to wait
636- for the request to complete. Note that if ``retry`` is
637- specified, the timeout applies to each individual attempt.
638- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
639- that is provided to the method.
640-
641- Returns:
642- A :class:`~google.cloud.iam_credentials_v1.types.GenerateIdentityBindingAccessTokenResponse` instance.
643-
644- Raises:
645- google.api_core.exceptions.GoogleAPICallError: If the request
646- failed for any reason.
647- google.api_core.exceptions.RetryError: If the request failed due
648- to a retryable error and retry attempts failed.
649- ValueError: If the parameters are invalid.
650- """
651- # Wrap the transport method to add retry and timeout logic.
652- if "generate_identity_binding_access_token" not in self ._inner_api_calls :
653- self ._inner_api_calls [
654- "generate_identity_binding_access_token"
655- ] = google .api_core .gapic_v1 .method .wrap_method (
656- self .transport .generate_identity_binding_access_token ,
657- default_retry = self ._method_configs [
658- "GenerateIdentityBindingAccessToken"
659- ].retry ,
660- default_timeout = self ._method_configs [
661- "GenerateIdentityBindingAccessToken"
662- ].timeout ,
663- client_info = self ._client_info ,
664- )
665-
666- request = common_pb2 .GenerateIdentityBindingAccessTokenRequest (
667- name = name , scope = scope , jwt = jwt
668- )
669- if metadata is None :
670- metadata = []
671- metadata = list (metadata )
672- try :
673- routing_header = [("name" , name )]
674- except AttributeError :
675- pass
676- else :
677- routing_metadata = google .api_core .gapic_v1 .routing_header .to_grpc_metadata (
678- routing_header
679- )
680- metadata .append (routing_metadata )
681-
682- return self ._inner_api_calls ["generate_identity_binding_access_token" ](
683- request , retry = retry , timeout = timeout , metadata = metadata
684- )
0 commit comments