---
sidebar:
  label: roboto.storage.credentials
  order: 2
title: roboto.storage.credentials
---
## Module Contents

### RobotoCredentials

```python
class roboto.storage.credentials.RobotoCredentials(/, **data: Any)
```

`from roboto.storage import RobotoCredentials`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/credentials.py#L16-L81)

Bases: `pydantic.BaseModel`

Temporary AWS credentials for reading or writing files in one S3 bucket where Roboto stores them.

`GET /v1/datasets/id/{dataset_id}/credentials` and `GET /v1/files/association/id/{association_id}/credentials` return one for each bucket that holds the resource's files, and `GET /v1/files/upload/{upload_id}/credentials` returns the one an upload writes with. [`download()`](/docs/reference/python-sdk/roboto/storage/file_service#roboto.storage.file_service.FileService.download) and [`upload()`](/docs/reference/python-sdk/roboto/storage/file_service#roboto.storage.file_service.FileService.upload) fetch them to move file contents. They stop working at `expiration`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **RobotoCredentials.access_key_id** (`str`): AWS access key ID of the credentials.

- **RobotoCredentials.bucket** (`str`): Name of the S3 bucket the credentials reach.

- **RobotoCredentials.expiration** (`datetime.datetime`): Time the credentials expire.

- **RobotoCredentials.region** (`str`): AWS region of `bucket`.

- **RobotoCredentials.required_prefix** (`str`): Key prefix in `bucket` under which Roboto stores the files of the resource the credentials were issued for.

  In a bucket Roboto manages, the credentials reach only keys under this prefix. In a bucket an organization brings to Roboto, credentials for a dataset's or topic's files reach the whole bucket.

- **RobotoCredentials.secret_access_key** (`str`): AWS secret access key of the credentials.

- **RobotoCredentials.send_requests_to** (`str | None`) = `None`: URL that receives the requests signed with these credentials in place of S3, or `None` if they go to S3.

  Each request is still signed for S3, then sent to this URL followed by the host and path it was signed for, with its query unchanged: a request signed for `https://<host>/<path>?<query>` goes to `<send_requests_to>/<host>/<path>?<query>`.

- **RobotoCredentials.session_token** (`str`): AWS session token to send with `access_key_id` and `secret_access_key`.

#### RobotoCredentials.is_expired()

```python
def is_expired() -> bool
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/credentials.py#L59-L61)

Return whether the credentials have expired, as of now.

**Returns**

- `bool`

#### RobotoCredentials.to_dict()

```python
def to_dict() -> dict[str, Any]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/credentials.py#L63-L65)

Return the credentials as a JSON-compatible dictionary, with `expiration` as an ISO 8601 string.

**Returns**

- `dict[str, Any]`

#### RobotoCredentials.to_object_store_credentials()

```python
def to_object_store_credentials() -> roboto.storage.object_store.Credentials
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/credentials.py#L67-L81)

Return the credentials as the [`Credentials`](/docs/reference/python-sdk/roboto/storage/object_store/object_store#roboto.storage.object_store.object_store.Credentials) an object store reads.

[`download()`](/docs/reference/python-sdk/roboto/storage/file_service#roboto.storage.file_service.FileService.download) and [`upload()`](/docs/reference/python-sdk/roboto/storage/file_service#roboto.storage.file_service.FileService.upload) convert the credentials they fetch through it, so most code never calls it. `bucket` and `required_prefix` are left out; the object store takes the bucket from each file's URI.

**Returns**

- `roboto.storage.object_store.Credentials`
