Skip to content

Commit

Permalink
test refreshtoken
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Sep 20, 2023
1 parent 0c1720a commit 09aca94
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,44 @@
https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
#>
[OutputType([PSCustomObject])]
[CmdletBinding()]
[CmdletBinding(DefaultParameterSetName = 'DeviceCode')]
param(
# The `device_code` used to request the access token.
[Parameter(Mandatory)]
[string] $DeviceCode,

# The Client ID of the GitHub App.
[Parameter()]
[Parameter(Mandatory)]
[string] $ClientID,

# The `device_code` used to request the access token.
[Parameter(
Mandatory,
ParameterSetName = 'DeviceCode'
)]
[string] $DeviceCode,

# The refresh token used create a new access token.
[Parameter()]
[Parameter(
Mandatory,
ParameterSetName = 'RefreshToken'
)]
[string] $RefreshToken
)

$body = @{
'client_id' = $ClientID
'grant_type' = 'urn:ietf:params:oauth:grant-type:device_code'
}

if ($PSBoundParameters.ContainsKey('RefreshToken')) {
$body += @{
'refresh_token' = $RefreshToken
}
}

if ($PSBoundParameters.ContainsKey('DeviceCode')) {
$body += @{
'device_code' = $DeviceCode
}
}

$RESTParams = @{
Uri = 'https://github.com/login/oauth/access_token'
Method = 'POST'
Expand Down

0 comments on commit 09aca94

Please sign in to comment.