1.55.4 (latest) 1.55.3 1.52.0 1.50.1 1.49.0 1.48.1 1.47.1 1.46.0 1.45.2 Reference documentation and code samples for the Google Auth Library Client class StaticCredentials.

Provides a set of credentials that always returns a pre-issued access token.

No token exchange or HTTP request is ever performed; the supplied token is
returned as-is. This is useful for development and testing, or when an access
token has already been obtained through some other means and simply needs to
be handed to the auth middleware.

```php
use Google\Auth\Credentials\StaticCredentials;
use Google\Auth\Middleware\AuthTokenMiddleware;

$creds = new StaticCredentials('ya29.my-access-token');
$middleware = new AuthTokenMiddleware($creds);
```

## Namespace

Google \\ Auth \\ Credentials

## Implements

[FetchAuthTokenInterface](https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.md.txt)

## Methods

### __construct

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `accessToken` | `string` The pre-issued OAuth2 access token to use. |
| `expiresIn` | `int` \[optional\] The lifetime of the token in seconds, used to populate its expiration. Defaults to 3600 (one hour). |

### fetchAuthToken

Returns the static access token supplied to the constructor.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `httpHandler` | `callable|null` Unused; present for interface compatibility. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array{access_token: string, expires_at: int}` |   |

### getCacheKey

Returns a cache key derived from the supplied token. Caching a static token
has no real benefit, but a stable, token-specific key ensures a shared cache
pool never returns another credential's token.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### getLastReceivedToken

Returns an associative array with the token and
expiration time.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array{access_token: string, expires_at: int}` |   |