Credentials

Using a Fetched Access Token

FetchAccessToken(out string accessToken) (see OAuth and Service Account) returns a short-lived bearer token for Google, Azure, or AWS. Pass it to GPAL.RESTClient.WithHeader("Authorization", "Bearer " + accessToken) to call the provider's REST API directly, for endpoints not already covered by GoogleSheets or GoogleDrive.

Examples

GPAL Fluent: High-level fluent C# API

//WithHeader adds the Authorization header to the request. This pattern works for any Google/Azure/AWS REST endpoint not already wrapped by a GPAL subsystem (GoogleSheets, GoogleDrive).

// Fetch an access token, then call a REST API with it directly

GPAL.CredentialsFor(CredentialServiceType.Google)

.WithUsername("you@example.com")

.WithPassword("your-password")

.WithServiceAccountKey(GPAL.FileFor("service-account.json"))

.WithScope(OAuthScope.Google_Drive)

.FetchAccessToken(out string accessToken);


GPAL.RESTClient

.WithAPIBase("https://www.googleapis.com")

.WithEndpoint("/drive/v3/about?fields=user")

.WithHeader("Authorization", "Bearer " + accessToken)

.Execute();

💬 Ask GPAL