OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
gslib
/
vendored
/
oauth2client
/
oauth2client
/
contrib
/
__pycache__
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/11/2025 08:19:48 AM
rwxr-xr-x
📄
__init__.cpython-39.pyc
388 bytes
02/11/2025 08:19:48 AM
rw-r--r--
📄
_metadata.cpython-39.pyc
3.7 KB
02/11/2025 08:19:48 AM
rw-r--r--
📄
devshell.cpython-39.pyc
4.84 KB
02/11/2025 08:19:48 AM
rw-r--r--
📄
gce.cpython-39.pyc
5.29 KB
02/11/2025 08:19:48 AM
rw-r--r--
📄
multiprocess_file_storage.cpython-39.pyc
10.71 KB
02/11/2025 08:19:48 AM
rw-r--r--
Editing: _metadata.cpython-39.pyc
Close
a ��ao � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddl m Z ddl mZ ddl mZ e� d�Zesre� d d �Zd�e�Zdd iZedfdd�Zddd�Zddd�ZdS )zProvides helper methods for talking to the Compute Engine metadata server. See https://cloud.google.com/compute/docs/metadata � N)�http_client)�parse)�_helpers)�client)� transport�GCE_METADATA_HOST�GCE_METADATA_ROOTzmetadata.google.internalzhttp://{}/computeMetadata/v1/zMetadata-Flavor�Googlec C sv t �||�}t�|d|�}tj| |td�\}}|jtj kr`t� |�}|d dkrZt�|�S |S nt� d�||���dS )a� Fetch a resource from the metadata server. Args: http: an object to be used to make HTTP requests. path: A string indicating the resource to retrieve. For example, 'instance/service-accounts/default' root: A string indicating the full path to the metadata server root. recursive: A boolean indicating whether to do a recursive query of metadata. See https://cloud.google.com/compute/docs/metadata#aggcontents Returns: A dictionary if the metadata server returns JSON, otherwise a string. Raises: http_client.HTTPException if an error corrured while retrieving metadata. � recursive)�headerszcontent-typezapplication/jsonzTFailed to retrieve {0} from the Google Compute Enginemetadata service. Response: {1}N)�urlparse�urljoinr �_add_query_parameterr �request�METADATA_HEADERS�statusr �OK�_from_bytes�json�loads� HTTPException�format)�http�path�rootr �url�response�content�decoded� r �I/opt/gsutil/gslib/vendored/oauth2client/oauth2client/contrib/_metadata.py�get. s � ��r! �defaultc C s t | d�|�dd�S )aq Get information about a service account from the metadata server. Args: http: an object to be used to make HTTP requests. service_account: An email specifying the service account for which to look up information. Default will be information for the "default" service account of the current compute engine instance. Returns: A dictionary with information about the specified service account, for example: { 'email': '...', 'scopes': ['scope', ...], 'aliases': ['default', '...'] } zinstance/service-accounts/{0}/T)r )r! r )r �service_accountr r r �get_service_account_infoS s �r$ c C s4 t | d�|��}t�� tj|d d� }|d |fS )a# Fetch an oauth token for the Args: http: an object to be used to make HTTP requests. service_account: An email specifying the service account this token should represent. Default will be a token for the "default" service account of the current compute engine instance. Returns: A tuple of (access token, token expiration), where access token is the access token as a string and token expiration is a datetime object that indicates when the access token will expire. z#instance/service-accounts/{0}/token� expires_in)�seconds�access_token)r! r r �_UTCNOW�datetime� timedelta)r r# Z token_json�token_expiryr r r � get_tokenl s � �r, )r"