Credentials

Credentials Configuration (CredentialsConfig)

Every GPAL.Credentials object loads a CredentialsConfig automatically via its Config property. CredentialsConfig.Load() reads ./credentialsConfig.json if it exists, falling back to built-in defaults for Google, Azure, AWS, and Bitwarden endpoints, OAuth redirect URIs, and the form field names used when building token requests. Call Save() after changing values to persist them for future runs. Both Load() and Save() accept an optional GPALFile: pass one to redirect to a different path, and that path becomes the new in-session default so subsequent no-arg calls use it automatically.

NOTE

CredentialsConfig.UseRestRedirect (default true) controls how OAuth authorization codes are obtained: when true, GPAL polls GPALRESTAPI's get-access-token endpoint after the redirect; when false, the user is prompted to paste the authorization code manually.

Examples

GPAL Fluent: High-level fluent C# API

//CredentialsConfig.Load() and Save() default to ./credentialsConfig.json. Pass a GPALFile to either call to redirect to a custom path -- that path becomes the session default for all subsequent no-arg calls in the same run.

// Load from default path, modify, and save back

var config = CredentialsConfig.Load();

config.BitwardenAuthBase = "https://identity.bitwarden.eu";

config.BitwardenVaultBase = "https://api.bitwarden.eu";

config.Save();


// Load from a custom path -- sets the session default

config = CredentialsConfig.Load(

GPAL.File.WithFileName("config/creds.json"));

config.GoogleRestRedirectUri = "http://localhost:3000/access-token";

config.Save(); // config/creds.json

config.Save(); // still config/creds.json


// Subsequent Credentials objects pick up the saved config automatically

var bwGrid = GPAL.Grid.ToGPALObject();

GPAL.CredentialsFor(CredentialServiceType.Bitwarden)

.WithServiceKey("client-id:client-secret")

.WithUsername("you@example.com")

.WithPassword("master-password")

.GetCredentialsFor("example.com")

.SaveTo(bwGrid);

💬 Ask GPAL