Buckets.Adapters.GCS.Auth (buckets v1.0.0-rc.2)
Google Cloud Storage authentication using service account credentials.
Handles JWT token generation and OAuth2 token exchange without external dependencies.
Summary
Functions
Exchanges a JWT token for an access token via Google's OAuth2 endpoint.
Generates a JWT token for Google service account authentication.
Gets an access token for GCS API access.
Get service account credentials from a location config.
Loads service account credentials from a file path.
Parse service account credentials from a JSON string.
Validates that service account credentials contain required fields.
Functions
exchange_jwt_for_token(jwt)
Exchanges a JWT token for an access token via Google's OAuth2 endpoint.
generate_jwt(credentials)
Generates a JWT token for Google service account authentication.
get_access_token(credentials)
Gets an access token for GCS API access.
Examples
iex> credentials = %{
...> "client_email" => "test@example.com",
...> "private_key" => "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
...> }
iex> Buckets.GCS.Auth.get_access_token(credentials)
{:ok, "ya29.c.Ko8..."}
get_credentials(config)
Get service account credentials from a location config.
load_credentials(path)
Loads service account credentials from a file path.
parse_credentials(credentials_json)
Parse service account credentials from a JSON string.
validate_credentials(credentials)
Validates that service account credentials contain required fields.