| OLD | NEW |
| 1 # Copyright (C) 2012 Google Inc. | 1 # Copyright 2014 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and | 12 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. | 13 # limitations under the License. |
| 14 | 14 |
| 15 """A keyring based Storage. | 15 """A keyring based Storage. |
| 16 | 16 |
| 17 A Storage for Credentials that uses the keyring module. | 17 A Storage for Credentials that uses the keyring module. |
| 18 """ | 18 """ |
| 19 | 19 |
| 20 __author__ = 'jcgregorio@google.com (Joe Gregorio)' | 20 __author__ = 'jcgregorio@google.com (Joe Gregorio)' |
| 21 | 21 |
| 22 import keyring | |
| 23 import threading | 22 import threading |
| 24 | 23 |
| 25 from client import Storage as BaseStorage | 24 import keyring |
| 26 from client import Credentials | 25 |
| 26 from oauth2client.client import Credentials |
| 27 from oauth2client.client import Storage as BaseStorage |
| 27 | 28 |
| 28 | 29 |
| 29 class Storage(BaseStorage): | 30 class Storage(BaseStorage): |
| 30 """Store and retrieve a single credential to and from the keyring. | 31 """Store and retrieve a single credential to and from the keyring. |
| 31 | 32 |
| 32 To use this module you must have the keyring module installed. See | 33 To use this module you must have the keyring module installed. See |
| 33 <http://pypi.python.org/pypi/keyring/>. This is an optional module and is not | 34 <http://pypi.python.org/pypi/keyring/>. This is an optional module and is not |
| 34 installed with oauth2client by default because it does not work on all the | 35 installed with oauth2client by default because it does not work on all the |
| 35 platforms that oauth2client supports, such as Google App Engine. | 36 platforms that oauth2client supports, such as Google App Engine. |
| 36 | 37 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 keyring.set_password(self._service_name, self._user_name, | 101 keyring.set_password(self._service_name, self._user_name, |
| 101 credentials.to_json()) | 102 credentials.to_json()) |
| 102 | 103 |
| 103 def locked_delete(self): | 104 def locked_delete(self): |
| 104 """Delete Credentials file. | 105 """Delete Credentials file. |
| 105 | 106 |
| 106 Args: | 107 Args: |
| 107 credentials: Credentials, the credentials to store. | 108 credentials: Credentials, the credentials to store. |
| 108 """ | 109 """ |
| 109 keyring.set_password(self._service_name, self._user_name, '') | 110 keyring.set_password(self._service_name, self._user_name, '') |
| OLD | NEW |