GeorepositoryCredential

class geodetic_engine.georepository.GeorepositoryCredential[source]

Bases: object

Fetches and caches an OAuth2 access token.

The token is requested with the client credentials grant, authenticating with HTTP Basic as required by the identity server, and reused until it is within the renewal skew of expiring.

Example

>>> credential = GeorepositoryCredential(
...     token_url="https://georepo.example.com/auth/connect/token",
...     client_id="...",
...     client_secret="...",
...     scope="GeoRepositoryAPI_Scope",
... )
>>> credential.authorization_header()
{'Authorization': 'Bearer ...'}
__init__(*, token_url, client_id, client_secret, scope, timeout=30.0, transport=None)[source]
authorization_header()[source]

Return an Authorization header, refreshing the token if needed.

Return type:

dict[str, str]

Returns:

A single-entry mapping suitable for merging into request headers.

Raises:

GeorepositoryAuthError – If a token cannot be obtained.

close()[source]

Close the underlying HTTP connection pool.

Return type:

None