
    I                     R    S r SSKrSSKrSSKJr  Sr " S S\R                  5      rg)zRA keyring based Storage.

A Storage for Credentials that uses the keyring module.
    N)clientz$jcgregorio@google.com (Joe Gregorio)c                   >   ^  \ rS rSrSrU 4S jrS rS rS rSr	U =r
$ )Storage   a  Store and retrieve a single credential to and from the keyring.

To use this module you must have the keyring module installed. See
<http://pypi.python.org/pypi/keyring/>. This is an optional module and is
not installed with oauth2client by default because it does not work on all
the platforms that oauth2client supports, such as Google App Engine.

The keyring module <http://pypi.python.org/pypi/keyring/> is a
cross-platform library for access the keyring capabilities of the local
system. The user will be prompted for their keyring password when this
module is used, and the manner in which the user is prompted will vary per
platform.

Usage::

    from oauth2client import keyring_storage

    s = keyring_storage.Storage('name_of_application', 'user1')
    credentials = s.get()

c                 f   > [         [        U ]  [        R                  " 5       S9  Xl        X l        g)zConstructor.

Args:
    service_name: string, The name of the service under which the
                  credentials are stored.
    user_name: string, The name of the user to store credentials for.
)lockN)superr   __init__	threadingLock_service_name
_user_name)selfservice_name	user_name	__class__s      7lib/third_party/oauth2client/contrib/keyring_storage.pyr
   Storage.__init__5   s)     	gt%9>>+;%<)#    c                     Sn[         R                  " U R                  U R                  5      nUb3   [        R
                  R                  U5      nUR                  U 5        U$ U$ ! [         a     U$ f = f)zMRetrieve Credential from file.

Returns:
    oauth2client.client.Credentials
N)	keyringget_passwordr   r   r   Credentialsnew_from_json	set_store
ValueError)r   credentialscontents      r   
locked_getStorage.locked_getA   s{     &&t'9'94??K$00>>wG%%d+ {  s   0A& &
A43A4c                 x    [         R                  " U R                  U R                  UR	                  5       5        g)zZWrite Credentials to file.

Args:
    credentials: Credentials, the credentials to store.
N)r   set_passwordr   r   to_json)r   r   s     r   
locked_putStorage.locked_putS   s,     	T//(002	4r   c                 \    [         R                  " U R                  U R                  S5        g)zXDelete Credentials file.

Args:
    credentials: Credentials, the credentials to store.
 N)r   r"   r   r   )r   s    r   locked_deleteStorage.locked_delete\   s      	T//"Er   )r   r   )__name__
__module____qualname____firstlineno____doc__r
   r   r$   r(   __static_attributes____classcell__)r   s   @r   r   r      s#    ,
$$4F Fr   r   )r.   r   r   oauth2clientr   
__author__r    r   r   <module>r4      s0   
    4
DFfnn DFr   