
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ d
 Zd Zej"                   ej$                  ej&                  j(                         G d dej*                                      Zy)z<Command to print an identity token for a specified audience.    )absolute_import)division)unicode_literals)
exceptions)gdch_credentials)base)log)requestsc                 8    | j                  ddt        dd       y )Nz--cred-fileT	CRED_FILEzPath to a credential file.requiredtypemetavarhelpadd_argumentstrparsers    8lib/surface/zone_management/auth/print_identity_token.pyAddCredFileArgr      s$    '  )    c                 8    | j                  ddt        dd       y )Nz
--audienceTAUDIENCEzOIntended recipient of the token. Currently, only one audience can be specified.r   r   r   s    r   AddAudienceArgr   %   s&    <  =r   c                   &    e Zd ZdZed        Zd Zy)IdentityTokenzPrint an identity token for a specified audience.

  ## EXAMPLES

    $ {command} --audience=https://example.com --cred-file=/tmp/cred.json
  c                 0    t        |        t        |        y )N)r   r   r   s    r   ArgszIdentityToken.Args9   s    66r   c                    t         j                  j                  |j                        }|j	                  |j
                        }	 |j                  t        j                                t        j                  j                  |j                         y # t        j                  $ r }t        j                  d|       Y d }~y d }~ww xY w)Nz!Failed to refresh credentials: %s)r   ServiceAccountCredentialsfrom_service_account_file	cred_filewith_gdch_audienceaudiencerefreshr
   GoogleAuthRequestgoogle_auth_exceptionsRefreshErrorr	   erroroutPrinttoken)selfargs
credentiales       r   RunzIdentityToken.Run>   s    22LLNN	
 
 ..t}}=J3356
 GGMM*""# ".. 	ii3Q7s   #B C&CCN)__name__
__module____qualname____doc__staticmethodr    r3    r   r   r   r   /   s       r   r   N)r7   
__future__r   r   r   google.authr   r)   google.oauth2r   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   r   r   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHADescribeCommandr   r9   r   r   <module>rD      su    C &  ' < * ( # ()= D%%++,D((  - r   