OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
gslib
/
vendored
/
oauth2client
/
oauth2client
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/11/2024 09:39:44 AM
rwxr-xr-x
📄
__init__.py
1002 bytes
12/16/2021 06:06:07 PM
rw-r--r--
📁
__pycache__
-
02/11/2025 08:19:48 AM
rwxr-xr-x
📄
_helpers.py
10.6 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
_openssl_crypt.py
4.45 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
_pkce.py
2.15 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
_pure_python_crypt.py
6.22 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
_pycrypto_crypt.py
4.02 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
client.py
81.34 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
clientsecrets.py
5.16 KB
12/16/2021 06:06:07 PM
rw-r--r--
📁
contrib
-
02/11/2025 08:19:48 AM
rwxr-xr-x
📄
crypt.py
8.25 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
file.py
2.67 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
service_account.py
27.55 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
tools.py
8.86 KB
12/16/2021 06:06:07 PM
rw-r--r--
📄
transport.py
10.12 KB
12/16/2021 06:06:07 PM
rw-r--r--
Editing: file.py
Close
# Copyright 2014 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Utilities for OAuth. Utilities for making it easier to work with OAuth 2.0 credentials. """ import os import threading from oauth2client import _helpers from oauth2client import client class Storage(client.Storage): """Store and retrieve a single credential to and from a file.""" def __init__(self, filename): super(Storage, self).__init__(lock=threading.Lock()) self._filename = filename def locked_get(self): """Retrieve Credential from file. Returns: oauth2client.client.Credentials Raises: IOError if the file is a symbolic link. """ credentials = None _helpers.validate_file(self._filename) try: f = open(self._filename, 'rb') content = f.read() f.close() except IOError: return credentials try: credentials = client.Credentials.new_from_json(content) credentials.set_store(self) except ValueError: pass return credentials def _create_file_if_needed(self): """Create an empty file if necessary. This method will not initialize the file. Instead it implements a simple version of "touch" to ensure the file has been created. """ if not os.path.exists(self._filename): old_umask = os.umask(0o177) try: open(self._filename, 'a+b').close() finally: os.umask(old_umask) def locked_put(self, credentials): """Write Credentials to file. Args: credentials: Credentials, the credentials to store. Raises: IOError if the file is a symbolic link. """ self._create_file_if_needed() _helpers.validate_file(self._filename) f = open(self._filename, 'w') f.write(credentials.to_json()) f.close() def locked_delete(self): """Delete Credentials file. Args: credentials: Credentials, the credentials to store. """ os.unlink(self._filename)