Add-GitHubApiKey
SYNOPSIS
Sets the GitHub token used to authenticate API calls
SYNTAX
AsPlainText (Default)
Add-GitHubApiKey [-ApiKey <string>]
AsSecureString
Add-GitHubApiKey -ApiKeySecureString <securestring>
ALIASES
This cmdlet has the following aliases,
- Get-GHAddApiKey
DESCRIPTION
The Add-GitHubApiKey function stores a GitHub token (personal access token, fine-grained token, GitHub App installation token or OAuth token) in memory as a SecureString. The token is sent as a Bearer token with every request
Token resolution order at request time 1. the key stored with this function 2. $env:GITHUB_TOKEN 3. $env:GH_TOKEN 4. anonymous requests (60 requests per hour per IP)
Use a token with the minimum permissions & repository access that are required
EXAMPLES
EXAMPLE 1
Add-GitHubApiKey
Prompts for the token & stores it as a SecureString
EXAMPLE 2
Add-GitHubApiKey -ApiKey 'ghp_12345'
Converts the string to a SecureString & stores it
EXAMPLE 3
'ghp_12345' | Add-GitHubApiKey
The token is passed in from the pipeline
EXAMPLE 4
Add-GitHubApiKey -ApiKeySecureString (Read-Host -AsSecureString)
Stores an existing SecureString
PARAMETERS
-ApiKey
Plain text token
If neither -ApiKey nor -ApiKeySecureString is used the function prompts for the token
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AsPlainText
Position: Named
IsRequired: false
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-ApiKeySecureString
A SecureString object containing the token
Type: System.Security.SecureString
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AsSecureString
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
System.String
{{ Fill in the Description }}
OUTPUTS
NOTES
Aliases: Get-GHAddApiKey
The token is kept in memory for the current session only, use Export-GitHubModuleSettings to save it