U
    {Zg                     @   s   d Z ddlZddlZddlZddlZddlZdZdZe	 ej
ddddd	ej
d
dddddej
dddddddej
dddejeeedddd Zedkre  dS )a
  Command-line tool for obtaining authorization and credentials from a user.

This tool uses the OAuth 2.0 Authorization Code grant as described in
`section 1.3.1 of RFC6749`_ and implemeted by
:class:`google_auth_oauthlib.flow.Flow`.

This tool is intended for assist developers in obtaining credentials
for testing applications where it may not be possible or easy to run a
complete OAuth 2.0 authorization flow, especially in the case of code
samples or embedded devices without input / display capabilities.

This is not intended for production use where a combination of
companion and on-device applications should complete the OAuth 2.0
authorization flow to get authorization from the users.

.. _section 1.3.1 of RFC6749: https://tools.ietf.org/html/rfc6749#section-1.3.1
    Nzgoogle-oauthlib-toolzcredentials.jsonz--client-secretsz<client_secret_json_file>Tz'Path to OAuth2 client secret JSON file.)metavarrequiredhelpz--scopez<oauth2 scope>z#API scopes to authorize access for.)multipler   r   r   z--savez<save_mode>FzSave the credentials to file.)Zis_flagr   show_defaultdefaultr   z--credentialsz<oauth2_credentials>z!Path to store OAuth2 credentials.)r   r   r   r   c           	   	   C   s   t jjj| |d}| }|j|j|j|j|j	|j
d}|r|d= tj|}|rhtj|sht| t|d}t|| W 5 Q R X td|  ntt| dS )a)  Command-line tool for obtaining authorization and credentials from a user.

    This tool uses the OAuth 2.0 Authorization Code grant as described
    in section 1.3.1 of RFC6749:
    https://tools.ietf.org/html/rfc6749#section-1.3.1

    This tool is intended for assist developers in obtaining credentials
    for testing applications or samples.

    This is not intended for production use where a combination of
    companion and on-device applications should complete the OAuth 2.0
    authorization flow to get authorization from the users.

    )scopes)tokenrefresh_token	token_uri	client_idclient_secretr   r	   wzcredentials saved: %sN)google_auth_oauthlibflowZInstalledAppFlowZfrom_client_secrets_fileZrun_local_serverr	   r
   r   r   r   r   ospathdirnameisdirmakedirsopenjsondumpclickZechodumps)	Zclient_secretsZscopesavecredentialsr   credsZ
creds_dataZconfig_pathoutfile r   F/tmp/pip-unpacked-wheel-bz4rx5ts/google_auth_oauthlib/tool/__main__.pymain.   s*    - 	
r!   __main__)__doc__r   r   os.pathr   Zgoogle_auth_oauthlib.flowr   ZAPP_NAMEZDEFAULT_CREDENTIALS_FILENAMEcommandoptionr   joinZget_app_dirr!   __name__r   r   r   r    <module>   sN   /