Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions GitHubConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -836,13 +836,14 @@ function Set-GitHubAuthentication
SecureString for use in future PowerShell sessions.

.EXAMPLE
$secureString = ("<Your Access Token>" | ConvertTo-SecureString)
$secureString = ("<Your Access Token>" | ConvertTo-SecureString -AsPlainText -Force)
$cred = New-Object System.Management.Automation.PSCredential "username is ignored", $secureString
Set-GitHubAuthentication -Credential $cred
$secureString = $null # clear this out now that it's no longer needed
$cred = $null # clear this out now that it's no longer needed

Uses the API token stored in the password field of the provided credential object for
authentication, and stores it in a file on the machine as a SecureString for use in
future PowerShell sessions.
Allows you to specify your access token as a plain-text string ("<Your Access Token>")
which will be securely stored on the machine for use in all future PowerShell sessions.

.EXAMPLE
Set-GitHubAuthentication -SessionOnly
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ access token.
securely cached to disk and will persist across all future PowerShell sessions.
If you ever wish to clear it in the future, just call `Clear-GitHubAuthentication`).

> For automated scenarios (like GithHub Actions) where you are dynamically getting the access token
> needed for authentication, refer to `Example 2` in `Get-Help Set-StoreBrokerAuthentication -Examples`
> for how to configure in a promptless fashion.
>
> Alternatively, you _could_ configure PowerShell itself to always pass in a plain-text access token
> to any command (by setting `$PSDefaultParameterValues["*-GitHub*:AccessToken"] = "<access token>"`),
> although keep in mind that this is insecure (any other process could access this plain-text value).

A number of additional configuration options exist with this module, and they can be configured
for just the current session or to persist across all future sessions with `Set-GitHubConfiguration`.
For a full explanation of all possible configurations, run the following:
Expand Down