GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.Credentials Class Reference
Inheritance diagram for GenerallyPositive.Credentials:
GenerallyPositive.ICredentials GenerallyPositive.IAllowKeyFromApiEndpoint GenerallyPositive.IAllowGetCredentials GenerallyPositive.IAllowCredentialsIntoCredentials GenerallyPositive.IAllowCredentialsServiceKeyWithCredentials GenerallyPositive.IAllowCredentialsPassword GenerallyPositive.IAllowCredentialsUsername GenerallyPositive.IAllowClientSecret GenerallyPositive.IAllowCredentialServiceType

Public Member Functions

IAllowCredentialsIntoCredentials WithScope (OAuthScope scope)
 Sets the OAuth scope to request when an access token is fetched.
IAllowCredentialsIntoCredentials WithAuthCode (string authCode)
 Supplies a previously-obtained OAuth authorization code, skipping the interactive authorization step.
IAllowCredentialsIntoCredentials WithRefreshToken (string refreshToken)
 Supplies a previously-obtained OAuth refresh token, used to fetch a new access token without re-authorizing.
IAllowCredentialsUsername WithService (CredentialServiceType serviceType)
 Selects which password manager or cloud identity service this credentials request targets.
IAllowCredentialsPassword WithUsername (string username)
 Sets the username, either as a credential to retrieve directly (with CredentialServiceType.None) or as part of WithCredentials' master login.
IAllowCredentialsServiceKeyWithCredentials WithPassword (string password)
 Sets the password, either as a credential to retrieve directly (with CredentialServiceType.None) or as part of WithCredentials' master login.
IAllowCredentialsServiceKeyWithCredentials WithWebAuth (WebAuthType webAuthType)
 How the site expects to be told who you are. A browser handed this credential acts on it accordingly, so the workflow says what kind of door it is rather than how to open it.
IAllowCredentialsServiceKeyWithCredentials WithAuthRedirectUrl (string redirectUrl)
 Where the OAuth redirect lands, and therefore what has to catch the token. This is the one setting that is not GPAL's to choose: it has to be the URI registered with the provider, because that is the only place the provider will send the browser. Its authority is where GPAL listens, or where it expects to find a GPALRestAPI already listening.
Defaults to whatever credentialsConfig.json holds, http://localhost:3000/access-token out of the box.
IAllowCredentialsServiceKeyWithCredentials WithAccessToken (string accessToken)
 A token the workflow already holds, for the schemes that present one: Bearer, X-Auth-Token, X-API-Key and api-key.
The same field an OAuth fetch fills in, so a token that was read out of a page or handed over by someone else is presented exactly as one GPAL fetched would be.
IAllowCredentialsIntoCredentials WithDomain (string domain)
 Restricts GetCredentialsFor/SaveTo results to vault items whose URL contains this domain. If not called, no domain filtering is applied.
IAllowClientSecret WithClientId (string clientId)
 Sets the OAuth client ID used to authenticate to ServiceType.
IAllowCredentialsIntoCredentials WithClientSecret (string clientSecret)
 Sets the OAuth client secret and derives ServiceKey as "ClientId:ClientSecret".
IAllowCredentialsIntoCredentials WithServiceKey (string key)
 Service key is a custom string consisting of your ClientID:ClientSecret.
IAllowCredentialsIntoCredentials WithKeyFromEnv (string envVariableName)
 Like WithServiceKey, but reads the key from an environment variable (checking process, user, then machine scope) instead of taking it as a literal string.
IAllowKeyFromApiEndpoint WithKeyFromApi (IRESTClient restClient)
 Like WithServiceKey, but fetches the key via a GET request made with the supplied, already-configured RESTClient. Must be followed by .WithEndpoint(endpoint) to specify which endpoint returns the key, e.g. GPAL.CredentialsFor(CredentialServiceType.StaticKey).WithKeyFromApi(restClient).WithEndpoint("ANTKEY").ToGPALObject().
IAllowCredentialsIntoCredentials WithEndpoint (string endpoint)
 Completes .WithKeyFromApi(restClient) by calling the given endpoint on that RESTClient and using the returned value as the service key (see WithServiceKey).
IAllowCredentialsIntoCredentials WithServiceAccountKey (GPALFile serviceAccountKeyFile)
 Loads a Google Cloud service account key from a JSON key file, used to fetch an access token without an interactive OAuth flow.
IAllowCredentialsIntoCredentials WithServiceAccountKey (string serviceAccountKey)
 Supplies a Google Cloud service account key as a raw JSON string, used to fetch an access token without an interactive OAuth flow.
IAllowCredentialsIntoCredentials WithServiceAccountKey (GoogleServiceAccountKey serviceAccountKey)
 Supplies a Google Cloud service account key as a deserialized object, used to fetch an access token without an interactive OAuth flow.
IAllowCredentialsIntoCredentials GetCredentialsFor (string target)
 Sets the search term used to find a matching item in the target password manager (e.g. a site name or URL), and ensures an access token is available for ServiceType.
IAllowCredentialsIntoCredentials WithCredentials (ICredentials credentials)
 Supplies the login (master) credentials used to authenticate to the credential service itself (e.g. your Bitwarden/LastPass/1Password account), as an alternative to calling .WithUsername(...).WithPassword(...)/.WithClientId(...)/etc. directly.
.WithService(serviceType) still determines which service/vault is queried by GetCredentialsFor/SaveTo; only the authentication fields are copied from credentials .
IAllowGetCredentials SaveTo (IGPALGrid< string > grid)
 Looks up the credential matching .GetCredentialsFor's target (filtered by .WithDomain if set) and appends a [Username, Password] row to the given grid.
Typical usage: .WithSelector(usernameSelector).WithSelector(passwordSelector).FillInFrom(grid).LeftClick(loginSelector).
ICredentials ToGPALObject ()
 Fluent interface to return this credentials object as an ICredentials.
void FetchAccessToken (out string accessToken)
 Fetches a new access token for ServiceType using the credentials/configuration supplied so far, and stores it in AccessToken/IssueTime/ExpiresIn.

Properties

string Username [get]
 Username supplied via .WithUsername, or the username field returned from a vault item.
string ServiceKey [get]
 Combined "ClientId:ClientSecret" service key supplied via .WithServiceKey or derived from .WithClientId/.WithClientSecret.
WebAuthType WebAuthType [get]
 How the site expects to be told who you are, supplied via .WithWebAuth. Read by a browser this credential is given to, which is what decides whether anything can be done before the first request.
string ClientId [get, set]
 OAuth client ID supplied via .WithClientId or derived from .WithServiceKey.
string ClientSecret [get, set]
 OAuth client secret supplied via .WithClientSecret or derived from .WithServiceKey.
string AccessToken [get, set]
 Most recently fetched access token for ServiceType, set by FetchAccessToken/GetCredentialsFor.
string Target [get]
 Search term supplied via GetCredentialsFor, used by the password manager handlers to find a matching vault item.
string Domain [get]
 Optional URL filter supplied via .WithDomain, used to narrow vault matches down to a specific site.
CredentialsConfig Config [get]
 Endpoint/protocol configuration for the credential service handlers, loaded from ./credentialsConfig.json.
string AuthCode [get, set]
 OAuth authorization code supplied via .WithAuthCode, or retrieved automatically during the OAuth redirect flow.
string RefreshToken [get, set]
 OAuth refresh token supplied via .WithRefreshToken, or returned by a token exchange and used to renew AccessToken.
OAuthScope OAuthScope [get, set]
 OAuth scope requested via .WithScope when fetching an access token.

Detailed Description

Definition at line 639 of file Credentials.cs.

Member Function Documentation

◆ FetchAccessToken()

void GenerallyPositive.Credentials.FetchAccessToken ( out string accessToken)

Fetches a new access token for ServiceType using the credentials/configuration supplied so far, and stores it in AccessToken/IssueTime/ExpiresIn.

Parameters
accessTokenReceives the fetched access token, or an empty string if the fetch failed or ServiceType has no token fetcher.

Implements GenerallyPositive.IAllowGetCredentials.

Definition at line 1223 of file Credentials.cs.

◆ GetCredentialsFor()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.GetCredentialsFor ( string target)

Sets the search term used to find a matching item in the target password manager (e.g. a site name or URL), and ensures an access token is available for ServiceType.

Parameters
targetSearch term identifying the vault item to retrieve.
Returns
Fluent interface to continue building the credentials request, e.g. via .ToGPALObject() or .SaveTo(grid)

Implements GenerallyPositive.IAllowCredentialsIntoCredentials.

Definition at line 1137 of file Credentials.cs.

◆ SaveTo()

IAllowGetCredentials GenerallyPositive.Credentials.SaveTo ( IGPALGrid< string > grid)

Looks up the credential matching .GetCredentialsFor's target (filtered by .WithDomain if set) and appends a [Username, Password] row to the given grid.
Typical usage: .WithSelector(usernameSelector).WithSelector(passwordSelector).FillInFrom(grid).LeftClick(loginSelector).

Parameters
gridGrid to append the retrieved [Username, Password] row to.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsIntoCredentials.

Definition at line 1179 of file Credentials.cs.

◆ ToGPALObject()

ICredentials GenerallyPositive.Credentials.ToGPALObject ( )

Fluent interface to return this credentials object as an ICredentials.

Returns
This instance, as an ICredentials.

Implements GenerallyPositive.IAllowToGPALObject< TResult >.

Definition at line 1214 of file Credentials.cs.

◆ WithAccessToken()

IAllowCredentialsServiceKeyWithCredentials GenerallyPositive.Credentials.WithAccessToken ( string accessToken)

A token the workflow already holds, for the schemes that present one: Bearer, X-Auth-Token, X-API-Key and api-key.
The same field an OAuth fetch fills in, so a token that was read out of a page or handed over by someone else is presented exactly as one GPAL fetched would be.

Parameters
accessTokenThe token, as the site issued it and with no scheme word in front of it
Returns
Fluent interface to define more credential settings

Implements GenerallyPositive.IAllowCredentialsServiceKeyWithCredentials.

Definition at line 944 of file Credentials.cs.

◆ WithAuthCode()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithAuthCode ( string authCode)

Supplies a previously-obtained OAuth authorization code, skipping the interactive authorization step.

Parameters
authCodeAuthorization code returned by the OAuth provider's consent screen.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsIntoCredentials.

Definition at line 854 of file Credentials.cs.

◆ WithAuthRedirectUrl()

IAllowCredentialsServiceKeyWithCredentials GenerallyPositive.Credentials.WithAuthRedirectUrl ( string redirectUrl)

Where the OAuth redirect lands, and therefore what has to catch the token. This is the one setting that is not GPAL's to choose: it has to be the URI registered with the provider, because that is the only place the provider will send the browser. Its authority is where GPAL listens, or where it expects to find a GPALRestAPI already listening.
Defaults to whatever credentialsConfig.json holds, http://localhost:3000/access-token out of the box.

Parameters
redirectUrlThe redirect URI as registered with the provider, e.g. http://localhost:3117/access-token
Returns
Fluent interface to define more credential settings

Implements GenerallyPositive.IAllowCredentialsServiceKeyWithCredentials.

Definition at line 930 of file Credentials.cs.

◆ WithClientId()

IAllowClientSecret GenerallyPositive.Credentials.WithClientId ( string clientId)

Sets the OAuth client ID used to authenticate to ServiceType.

Parameters
clientIdOAuth client ID.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowClientId.

Definition at line 965 of file Credentials.cs.

◆ WithClientSecret()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithClientSecret ( string clientSecret)

Sets the OAuth client secret and derives ServiceKey as "ClientId:ClientSecret".

Parameters
clientSecretOAuth client secret.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowClientSecret.

Definition at line 975 of file Credentials.cs.

◆ WithCredentials()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithCredentials ( ICredentials credentials)

Supplies the login (master) credentials used to authenticate to the credential service itself (e.g. your Bitwarden/LastPass/1Password account), as an alternative to calling .WithUsername(...).WithPassword(...)/.WithClientId(...)/etc. directly.
.WithService(serviceType) still determines which service/vault is queried by GetCredentialsFor/SaveTo; only the authentication fields are copied from credentials .

Parameters
credentialsPreviously-built credentials (e.g. via GPAL.CredentialsFor(CredentialServiceType.None).WithUsername(...).WithPassword(...)) used to log in to the service named by .WithService
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsUsername.

Definition at line 1156 of file Credentials.cs.

◆ WithDomain()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithDomain ( string domain)

Restricts GetCredentialsFor/SaveTo results to vault items whose URL contains this domain. If not called, no domain filtering is applied.

Parameters
domainDomain or URL fragment to match against vault item URLs.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsIntoCredentials.

Definition at line 955 of file Credentials.cs.

◆ WithEndpoint()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithEndpoint ( string endpoint)

Completes .WithKeyFromApi(restClient) by calling the given endpoint on that RESTClient and using the returned value as the service key (see WithServiceKey).

Parameters
endpointREST endpoint name to call for the key, e.g. "ANTKEY".
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowKeyFromApiEndpoint.

Definition at line 1039 of file Credentials.cs.

◆ WithKeyFromApi()

IAllowKeyFromApiEndpoint GenerallyPositive.Credentials.WithKeyFromApi ( IRESTClient restClient)

Like WithServiceKey, but fetches the key via a GET request made with the supplied, already-configured RESTClient. Must be followed by .WithEndpoint(endpoint) to specify which endpoint returns the key, e.g. GPAL.CredentialsFor(CredentialServiceType.StaticKey).WithKeyFromApi(restClient).WithEndpoint("ANTKEY").ToGPALObject().

Parameters
restClientAlready-configured RESTClient (e.g. via .WithAPIBase(...)) used to fetch the key.
Returns
Fluent interface that only allows .WithEndpoint(endpoint) next.

Implements GenerallyPositive.IAllowCredentialsUsername.

Definition at line 1027 of file Credentials.cs.

◆ WithKeyFromEnv()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithKeyFromEnv ( string envVariableName)

Like WithServiceKey, but reads the key from an environment variable (checking process, user, then machine scope) instead of taking it as a literal string.

Parameters
envVariableNameName of the environment variable holding the API key.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsUsername.

Definition at line 1001 of file Credentials.cs.

◆ WithPassword()

IAllowCredentialsServiceKeyWithCredentials GenerallyPositive.Credentials.WithPassword ( string password)

Sets the password, either as a credential to retrieve directly (with CredentialServiceType.None) or as part of WithCredentials' master login.

Parameters
passwordPassword value.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsPassword.

Definition at line 903 of file Credentials.cs.

◆ WithRefreshToken()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithRefreshToken ( string refreshToken)

Supplies a previously-obtained OAuth refresh token, used to fetch a new access token without re-authorizing.

Parameters
refreshTokenRefresh token returned by a prior token exchange.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsIntoCredentials.

Definition at line 864 of file Credentials.cs.

◆ WithScope()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithScope ( OAuthScope scope)

Sets the OAuth scope to request when an access token is fetched.

Parameters
scopeScope to request.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsIntoCredentials.

Definition at line 844 of file Credentials.cs.

◆ WithService()

IAllowCredentialsUsername GenerallyPositive.Credentials.WithService ( CredentialServiceType serviceType)

Selects which password manager or cloud identity service this credentials request targets.

Parameters
serviceTypeService to query/store credentials with, or CredentialServiceType.None for username/password supplied directly.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialServiceType.

Definition at line 881 of file Credentials.cs.

◆ WithServiceAccountKey() [1/3]

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithServiceAccountKey ( GoogleServiceAccountKey serviceAccountKey)

Supplies a Google Cloud service account key as a deserialized object, used to fetch an access token without an interactive OAuth flow.

Parameters
serviceAccountKeyService account key object, normally loaded from a JSON key file.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowClientId.

Definition at line 1105 of file Credentials.cs.

◆ WithServiceAccountKey() [2/3]

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithServiceAccountKey ( GPALFile serviceAccountKeyFile)

Loads a Google Cloud service account key from a JSON key file, used to fetch an access token without an interactive OAuth flow.

Parameters
serviceAccountKeyFileGPALFile pointing at the service account JSON key file.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowClientId.

Definition at line 1063 of file Credentials.cs.

◆ WithServiceAccountKey() [3/3]

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithServiceAccountKey ( string serviceAccountKey)

Supplies a Google Cloud service account key as a raw JSON string, used to fetch an access token without an interactive OAuth flow.

Parameters
serviceAccountKeyService account key JSON contents.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowClientId.

Definition at line 1084 of file Credentials.cs.

◆ WithServiceKey()

IAllowCredentialsIntoCredentials GenerallyPositive.Credentials.WithServiceKey ( string key)

Service key is a custom string consisting of your ClientID:ClientSecret.

Parameters
keyCombined "ClientId:ClientSecret" service key.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsUsername.

Definition at line 986 of file Credentials.cs.

◆ WithUsername()

IAllowCredentialsPassword GenerallyPositive.Credentials.WithUsername ( string username)

Sets the username, either as a credential to retrieve directly (with CredentialServiceType.None) or as part of WithCredentials' master login.

Parameters
usernameUsername/login value.
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialsUsername.

Definition at line 892 of file Credentials.cs.

◆ WithWebAuth()

IAllowCredentialsServiceKeyWithCredentials GenerallyPositive.Credentials.WithWebAuth ( WebAuthType webAuthType)

How the site expects to be told who you are. A browser handed this credential acts on it accordingly, so the workflow says what kind of door it is rather than how to open it.

Parameters
webAuthTypeBasic, Digest, Proxy, Bearer, or Form when the credential is only being held for a login page the workflow drives itself
Returns
Fluent interface to define more credential settings

Implements GenerallyPositive.IAllowCredentialsServiceKeyWithCredentials.

Definition at line 915 of file Credentials.cs.

Property Documentation

◆ AccessToken

string GenerallyPositive.Credentials.AccessToken
getset

Most recently fetched access token for ServiceType, set by FetchAccessToken/GetCredentialsFor.

Definition at line 677 of file Credentials.cs.

◆ AuthCode

string GenerallyPositive.Credentials.AuthCode
getset

OAuth authorization code supplied via .WithAuthCode, or retrieved automatically during the OAuth redirect flow.

Definition at line 693 of file Credentials.cs.

◆ ClientId

string GenerallyPositive.Credentials.ClientId
getset

OAuth client ID supplied via .WithClientId or derived from .WithServiceKey.

Definition at line 669 of file Credentials.cs.

◆ ClientSecret

string GenerallyPositive.Credentials.ClientSecret
getset

OAuth client secret supplied via .WithClientSecret or derived from .WithServiceKey.

Definition at line 673 of file Credentials.cs.

◆ Config

CredentialsConfig GenerallyPositive.Credentials.Config
get

Endpoint/protocol configuration for the credential service handlers, loaded from ./credentialsConfig.json.

Definition at line 689 of file Credentials.cs.

◆ Domain

string GenerallyPositive.Credentials.Domain
get

Optional URL filter supplied via .WithDomain, used to narrow vault matches down to a specific site.

Definition at line 685 of file Credentials.cs.

◆ OAuthScope

OAuthScope GenerallyPositive.Credentials.OAuthScope
getset

OAuth scope requested via .WithScope when fetching an access token.

Definition at line 701 of file Credentials.cs.

◆ RefreshToken

string GenerallyPositive.Credentials.RefreshToken
getset

OAuth refresh token supplied via .WithRefreshToken, or returned by a token exchange and used to renew AccessToken.

Definition at line 697 of file Credentials.cs.

◆ ServiceKey

string GenerallyPositive.Credentials.ServiceKey
get

Combined "ClientId:ClientSecret" service key supplied via .WithServiceKey or derived from .WithClientId/.WithClientSecret.

Definition at line 656 of file Credentials.cs.

◆ Target

string GenerallyPositive.Credentials.Target
get

Search term supplied via GetCredentialsFor, used by the password manager handlers to find a matching vault item.

Definition at line 681 of file Credentials.cs.

◆ Username

string GenerallyPositive.Credentials.Username
get

Username supplied via .WithUsername, or the username field returned from a vault item.

Definition at line 648 of file Credentials.cs.

◆ WebAuthType

WebAuthType GenerallyPositive.Credentials.WebAuthType
get

How the site expects to be told who you are, supplied via .WithWebAuth. Read by a browser this credential is given to, which is what decides whether anything can be done before the first request.

Definition at line 661 of file Credentials.cs.


The documentation for this class was generated from the following file: