Test-GitHubApiKey
SYNOPSIS
Tests the GitHub token
SYNTAX
__AllParameterSets
Test-GitHubApiKey
ALIASES
This cmdlet has the following aliases,
- Get-GHTestApiKey
DESCRIPTION
The Test-GitHubApiKey function calls GET /user with the token that would be used for a request (stored key, $env:GITHUB_TOKEN, $env:GH_TOKEN) & returns the result
The function never throws, a failure is returned as an object with Success = $false
Scopes are only returned for classic personal access tokens
EXAMPLES
EXAMPLE 1
Test-GitHubApiKey
Returns an object with Success, StatusCode, Login, Scopes, RateLimit, TokenSource & Message
EXAMPLE 2
(Test-GitHubApiKey).Success
Returns $true when the token is valid
PARAMETERS
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
OUTPUTS
NOTES
Aliases: Get-GHTestApiKey
GitHub App installation tokens cannot call GET /user & will report a failure with status 403