
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r  SSKJr  SSKJr   " S S	\R                   5      r " S
 S\R                   5      rS rSS jrg)z Manages logic for refresh token.    )absolute_import)division)unicode_literals)
exceptions)store)clientc                       \ rS rSrSrSrg)LoadingCredentialsError   z/Reraise on oauth2client and google-auth errors. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       0lib/googlecloudsdk/api_lib/auth/refresh_token.pyr
   r
      s    7r   r
   c                       \ rS rSrSrSrg)UnsupportedCredentialsType"   z2Raised when credentials do not have refresh token.r   Nr   r   r   r   r   r   "   s    :r   r   c                 \    [         R                  " USS9n[         R                  " X5        U$ )zAActivates credentials for given account with given refresh token.Tuse_google_auth)c_storeAcquireFromTokenActivateCredentials)accountrefresh_tokencredss      r   r   r   &   s.     
"
"T+% 
g-	,r   Nc                 
    [         R                  " U SS9n[        USS5      nUc  [        SR                  U 5      5      eU$ ! [        R                  [        R
                  4 a    [        R                  " [        5      ef = f)zReturns refresh token for given account.

Args:
  account: str, usually email like string,
      if not provided current account is used.

Returns:
  str: refresh token

Raises:
  UnsupportedCredentialsType: if credentials are not user credentials.
Tr   r    Nz:Credentials for account {0} do not support refresh tokens.)r   Loadr   Errorgoogle_auth_exceptionsGoogleAuthErrorcalliope_exceptionsNewErrorFromCurrentExceptionr
   getattrr   format)r   r!   r    s      r   GetForAccountr+   1   s    !LL$7E
 %$7-
$D	  
 ,,.>>	? !

:
:! !!s   A ?B)N)r   
__future__r   r   r   googlecloudsdk.callioper   r'   googlecloudsdk.coregooglecloudsdk.core.credentialsr   r   oauth2clientr   google.authr%   r$   r
   r   r   r+   r   r   r   <module>r2      sP     ' &  ' E * <  <8j.. 8;!1!1 ;r   