Documentation
¶
Overview ¶
Package googleauth authenticates the REST catalog client with Google credentials, for catalogs such as BigLake. It is an optional backend: importing it (even as a blank import) registers the "google" auth type, so that rest.auth.type=google works, and it keeps the Google auth libraries out of the core catalog/rest package.
import (
"github.com/apache/iceberg-go/catalog"
_ "github.com/apache/iceberg-go/catalog/rest/googleauth"
)
cat, err := catalog.Load(ctx, "biglake", iceberg.Properties{
"type": "rest",
"uri": "https://biglake.googleapis.com/iceberg/v1/restcatalog",
"warehouse": "gs://my-bucket",
"rest.auth.type": "google",
})
The properties match Iceberg Java's GoogleAuthManager:
- gcp.auth.credentials-path: a credentials JSON file, such as a service account key.
- gcp.auth.credentials-json: the same JSON, inline.
- gcp.auth.scopes: comma-separated OAuth scopes, by default https://www.googleapis.com/auth/cloud-platform.
When neither credentials property is set, Application Default Credentials are used. Setting both is an error.
These properties, like rest.auth.type, are read only from the properties the client supplies, never from the server's /v1/config response. The credentials JSON may be of any type the Google auth library accepts, including external account configurations that fetch tokens from other hosts, so it must come from a source you control.
Token requests don't go through the catalog's HTTP client, so a transport, TLS config or proxy configured on the catalog doesn't apply to them, as in Java. They use a client with the default transport and a 60-second timeout. To use a specific client, put it in the context's oauth2.HTTPClient value when loading the catalog, or build the source with TokenSource and pass rest.NewOAuth2AuthManager(ts) to rest.WithAuthManager. One exception: on Google Cloud compute, Application Default Credentials come from the metadata server, which the Google library always reaches through its own client.
Index ¶
Constants ¶
const ( CredentialsPathKey = "gcp.auth.credentials-path" CredentialsJSONKey = "gcp.auth.credentials-json" ScopesKey = "gcp.auth.scopes" )
Property names, as in Iceberg Java's GoogleAuthManager.
const DefaultScopes = "https://www.googleapis.com/auth/cloud-platform"
DefaultScopes is the scope requested when gcp.auth.scopes is unset.
Variables ¶
This section is empty.
Functions ¶
func TokenSource ¶
func TokenSource(ctx context.Context, props iceberg.Properties) (oauth2.TokenSource, error)
TokenSource returns a token source for the Google credentials that props describe, using the gcp.auth.* properties. It is what rest.auth.type=google uses, exported for callers that build their own AuthManager.
Tokens are fetched after TokenSource returns, so the source keeps ctx's values but not its cancellation.
Types ¶
This section is empty.