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.IAllowCredentialSettings GenerallyPositive.IAllowOAuthClient GenerallyPositive.IAllowCredentialsPassword GenerallyPositive.IAllowUsernameOrKey GenerallyPositive.IAllowClientSecret GenerallyPositive.IAllowCredentialMethod GenerallyPositive.IAllowCredentialServiceType

Public Member Functions

IAllowCredentialSettings WithScope (OAuthScope scope)
 Sets the OAuth scope to request when an access token is fetched.
IAllowCredentialSettings WithAuthCode (string authCode)
 Supplies a previously-obtained OAuth authorization code, skipping the interactive authorization step.
IAllowCredentialSettings WithRefreshToken (string refreshToken)
 Supplies a previously-obtained OAuth refresh token, used to fetch a new access token without re-authorizing.
IAllowCredentialMethod 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.
IAllowOAuthClient WithPassword (string password)
 Sets the password, either as a credential to retrieve directly (with CredentialServiceType.None) or as part of WithCredentials' master login.
IAllowOAuthClient 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.
IAllowOAuthClient 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.
IAllowOAuthClient 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.
IAllowCredentialSettings 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.
IAllowCredentialSettings WithClientSecret (string clientSecret)
 Sets the OAuth client secret and derives ServiceKey as "ClientId:ClientSecret".
IAllowCredentialSettings WithServiceKey (string key)
 Service key is a custom string consisting of your ClientID:ClientSecret.
IAllowCredentialSettings 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().
IAllowCredentialSettings 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).
IAllowCredentialSettings 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.
IAllowCredentialSettings 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.
IAllowCredentialSettings 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.
IAllowCredentialSettings WithMasterCredentials (ICredentials masterCredentials)
 Supplies the login for the credential service itself, your Bitwarden, LastPass or 1Password account, instead of setting those fields on this request one call at a time.
IAllowCredentialSettings 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.
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 1231 of file Credentials.cs.

◆ GetCredentialsFor()

IAllowCredentialSettings 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.IAllowCredentialSettings.

Definition at line 1171 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.IAllowCredentialSettings.

Definition at line 1187 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 1222 of file Credentials.cs.

◆ WithAccessToken()

IAllowOAuthClient 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.IAllowOAuthClient.

Definition at line 948 of file Credentials.cs.

◆ WithAuthCode()

IAllowCredentialSettings 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.IAllowCredentialSettings.

Definition at line 858 of file Credentials.cs.

◆ WithAuthRedirectUrl()

IAllowOAuthClient 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.IAllowOAuthClient.

Definition at line 934 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 969 of file Credentials.cs.

◆ WithClientSecret()

IAllowCredentialSettings 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 979 of file Credentials.cs.

◆ WithDomain()

IAllowCredentialSettings 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.IAllowCredentialSettings.

Definition at line 959 of file Credentials.cs.

◆ WithEndpoint()

IAllowCredentialSettings 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 1043 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.IAllowUsernameOrKey.

Definition at line 1031 of file Credentials.cs.

◆ WithKeyFromEnv()

IAllowCredentialSettings 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.IAllowUsernameOrKey.

Definition at line 1005 of file Credentials.cs.

◆ WithMasterCredentials()

IAllowCredentialSettings GenerallyPositive.Credentials.WithMasterCredentials ( ICredentials masterCredentials)

Supplies the login for the credential service itself, your Bitwarden, LastPass or 1Password account, instead of setting those fields on this request one call at a time.

Only the authentication fields are taken. Which vault is queried is still whatever WithService named, so one master login built once serves every lookup against every service.
This is not the WithCredentials that a browser, a mail server or GPAL.YouTube takes. Those are handed a credential to use. This one is handed the credential that opens the vault.

Parameters
masterCredentialsA credentials object already holding the login for the service
Returns
Fluent interface to continue building the credentials request

Implements GenerallyPositive.IAllowCredentialMethod.

Definition at line 1148 of file Credentials.cs.

◆ WithPassword()

IAllowOAuthClient 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 907 of file Credentials.cs.

◆ WithRefreshToken()

IAllowCredentialSettings 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.IAllowCredentialSettings.

Definition at line 868 of file Credentials.cs.

◆ WithScope()

IAllowCredentialSettings 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.IAllowCredentialSettings.

Definition at line 848 of file Credentials.cs.

◆ WithService()

IAllowCredentialMethod 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 885 of file Credentials.cs.

◆ WithServiceAccountKey() [1/3]

IAllowCredentialSettings 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 1109 of file Credentials.cs.

◆ WithServiceAccountKey() [2/3]

IAllowCredentialSettings 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 1067 of file Credentials.cs.

◆ WithServiceAccountKey() [3/3]

IAllowCredentialSettings 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 1088 of file Credentials.cs.

◆ WithServiceKey()

IAllowCredentialSettings 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.IAllowUsernameOrKey.

Definition at line 990 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.IAllowUsernameOrKey.

Definition at line 896 of file Credentials.cs.

◆ WithWebAuth()

IAllowOAuthClient 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.IAllowOAuthClient.

Definition at line 919 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: