Class GitHubCredentials
Used internally to obtain the current user's GitHub from enviroment variables or a secret manager like 1Password via an IProfileClient implementation.
Namespace: Neon.GitHub
Assembly: Neon.GitHub.dll
Syntax
public class GitHubCredentials
Properties
AccessToken
Returns the user's GitHub Personal Access Token (PAT) or
null
whenh unknown.
Declaration
public string AccessToken { get; }
Property Value
Type | Description |
---|---|
string |
Returns the user's GitHub email address.
Declaration
public string Email { get; }
Property Value
Type | Description |
---|---|
string |
Password
Returns the user's password or null
when unknown.
Declaration
public string Password { get; }
Property Value
Type | Description |
---|---|
string |
Username
Returns the user's GitHub username.
Declaration
public string Username { get; }
Property Value
Type | Description |
---|---|
string |
Methods
Load(string, string, string, string, IProfileClient)
Loads the current user's GitHub credentials and email address from the parameters passed, from environment variables of a password manager like 1Password accessed via an IProfileClient implementation.
Declaration
public static GitHubCredentials Load(string username = null, string accessToken = null, string password = null, string email = null, IProfileClient profileClient = null)
Parameters
Type | Name | Description |
---|---|---|
string | username | Optionally specifies the GitHub username. |
string | accessToken | Optionally specifies the GitHub Personal Access Token (PAT). |
string | password | Optionally specifies the password. |
string | Optionally specifies the GitHub email address for the current user. |
|
IProfileClient | profileClient | Optionally specifies the IProfileClient instance to be used for retrieving secrets.
You may also add your IProfileClient to ServiceContainer
and the instance will use that if this parameter is |
Returns
Type | Description |
---|---|
GitHubCredentials | The GitHubCredentials. |
Remarks
This works by first trying to obtain each part of the credentials via environment variables: GITHUB_USERNAME, GITHUB_PASSWORD GITHUB_PAT, and GITHUB_EMAIL.
note
accessToken is required and must be passed as explicit parameters or be located from environment variables or a password manager. password is optional.
For any credential parts that couldn't be located as environment variables, the method will attempt to load the missing parts as via an IProfileClient implementation, if available.
The method extracts the credentials from the GITHUB secret in the current user's vault as GITHUB[username], GITHUB[password], GITHUB[accesstoken], and GITHUB[email].