---
sidebar:
  label: roboto.http.request_decorators
  order: 5
title: roboto.http.request_decorators
---
## Module Contents

### BearerTokenDecorator

```python
class roboto.http.request_decorators.BearerTokenDecorator(token: str)
```

`from roboto.http import BearerTokenDecorator`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/request_decorators.py#L25-L55)

Request decorator that sends one fixed access token in each request's `Authorization` header.

Pass it to [`RobotoClient`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient) as `auth_decorator`. [`from_config()`](/docs/reference/python-sdk/roboto/http/roboto_client#roboto.http.roboto_client.RobotoClient.from_config) builds one from the configured access token.

**Parameters**

- **token** (`str`): Roboto access token to send, as `Bearer <token>`.

**Raises**

- [`RobotoDeprecatedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoDeprecatedException): The token is in the format Roboto issued before March 20, 2024, which begins with `robo_pat`.

### SigV4AuthDecorator

```python
class roboto.http.request_decorators.SigV4AuthDecorator(
    service: str = 'execute-api',
    credentials: Optional[Union[botocore.credentials.ReadOnlyCredentials, botocore.credentials.Credentials]] = None,
    region: Optional[str] = None,
)
```

`from roboto.http import SigV4AuthDecorator`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/request_decorators.py#L58-L168)

Request decorator that signs each request with AWS Signature Version 4.

Roboto's own services use it to call Roboto with their AWS identity; to send an access token, use `BearerTokenDecorator` instead. Role credentials, such as a container's, an EC2 instance's or an assumed role's, are temporary and rotate. Reading them again for each request keeps a long-lived process signing with current ones instead of being rejected as expired until it restarts.

**Parameters**

- **service** (`str`): Signing name of the AWS service to sign for, such as `execute-api` for API Gateway.
- **credentials** (`Optional[Union[botocore.credentials.ReadOnlyCredentials, botocore.credentials.Credentials]]`): Credentials to sign with. `botocore.credentials.ReadOnlyCredentials` are used as given for every request. A `botocore.credentials.Credentials` object, such as `botocore.credentials.RefreshableCredentials` for an assumed role, is read again for each request, so it can refresh itself before it expires. `None` resolves this process's own credentials through boto3 for each request.
- **region** (`Optional[str]`): AWS region to sign for. `None` uses `lookup_region`.

**Raises**

- `RuntimeError`: `credentials` is `None` and boto3 finds no AWS credentials for this process.
- `ValueError`: `region` is `None` and no region is configured.

#### SigV4AuthDecorator.lookup_credentials()

```python
@staticmethod
def lookup_credentials() -> botocore.credentials.ReadOnlyCredentials
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/request_decorators.py#L88-L102)

Return this process's current AWS credentials, as a new default boto3 session resolves them.

Building a `SigV4AuthDecorator` without `credentials` checks for them through it, so most code never calls it.

**Raises**

- `RuntimeError`: boto3 finds no AWS credentials for this process.

**Returns**

- `botocore.credentials.ReadOnlyCredentials`

#### SigV4AuthDecorator.lookup_region()

```python
@staticmethod
def lookup_region() -> str
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/request_decorators.py#L105-L121)

Return the AWS region to sign for when the constructor is given none.

Uses the default boto3 session's region, which comes from `AWS_DEFAULT_REGION` or the AWS config file, then the `AWS_REGION` environment variable.

**Raises**

- `ValueError`: None of these sets a region.

**Returns**

- `str`

### logger

```python
roboto.http.request_decorators.logger
```

`from roboto.http.request_decorators import logger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/request_decorators.py#L22-L22)
