Skip to content

Commit

Permalink
Fix mapping of PAT token into secretVault
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Sep 20, 2023
1 parent d5a47bc commit 374aa0e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/GitHub/public/Core/Connect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@
# $tokenType = 'token'
} else {
$tokenResponse = Invoke-GitHubDeviceCodeLogin
$script:Token = $tokenResponse.access_token # ghu_####
$tokenExpiresIn = $tokenResponse.expires_in # 28800 = 8 hours
$tokenExpirationDate = (Get-Date).AddSeconds($tokenExpiresIn) # 2021-09-28T21:00:00.0000000-04:00
$accessToken = $tokenResponse.access_token # ghu_####
$accessTokenExpiresIn = $tokenResponse.expires_in # 28800 = 8 hours
$accessTokenExpirationDate = (Get-Date).AddSeconds($accessTokenExpiresIn) # 2021-09-28T21:00:00.0000000-04:00
$refreshToken = $tokenResponse.refresh_token # ghr_########
$refreshTokenExpiresIn = $tokenResponse.refresh_token_expires_in # 15724800 = 6 months
$refreshTokenExpirationDate = (Get-Date).AddSeconds($refreshTokenExpiresIn) # 2022-03-28T21:00:00.0000000-04:00
# $tokenType = $tokenResponse.token_type # bearer
# $tokenScope = $tokenResponse.scope
Set-GithubConfig -Token $Token
Set-Secret -Name 'GitHub.access_token' -Secret $script:Token -Vault $Vault.Name
Set-Secret -Name 'GitHub.access_token.expirationDate' -Secret $tokenExpirationDate.toString() -Vault $Vault.Name
Set-GithubConfig -Token $accessToken
Set-Secret -Name 'GitHub.access_token.expirationDate' -Secret $accessTokenExpirationDate.toString() -Vault $Vault.Name
Set-Secret -Name 'GitHub.refresh_token' -Secret $refreshToken -Vault $Vault.Name
Set-Secret -Name 'GitHub.refresh_token.expirationDate' -Secret $refreshTokenExpirationDate.toString() -Vault $Vault.Name
}
Expand Down

0 comments on commit 374aa0e

Please sign in to comment.