From 5752e30e53024cb44d362a6f7ff7edb3a9fb5882 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 7 Nov 2024 16:48:26 +0100 Subject: [PATCH 1/3] $authClientID --- src/functions/public/Auth/Connect-GitHubAccount.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index a81c9f133..b03ee34f6 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -152,9 +152,13 @@ switch ($AuthType) { 'UAT' { Write-Verbose 'Logging in using device flow...' + Write-Verbose "Provided ClientID: [$ClientID]" + Write-Verbose "Stored ClientID: [$(Get-GitHubConfig -Name 'AuthClientID')]" + Write-Verbose "Default ClientID: [$($script:Auth.$Mode.ClientID)]" $authClientID = $ClientID ?? (Get-GitHubConfig -Name 'AuthClientID') ?? $script:Auth.$Mode.ClientID + Write-Verbose "Selected ClientID: [$authClientID]" + Write-Verbose "Using $Mode authentication..." if ($Mode -ne (Get-GitHubConfig -Name 'DeviceFlowType' -ErrorAction SilentlyContinue)) { - Write-Verbose "Using $Mode authentication..." $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -Scope $Scope -HostName $HostName } else { $accessTokenValidity = [datetime](Get-GitHubConfig -Name 'AccessTokenExpirationDate') - (Get-Date) From ebaa15e6e40ca1fa61827a1585f12bb3c3a2fe25 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 7 Nov 2024 16:48:50 +0100 Subject: [PATCH 2/3] Fix --- src/functions/public/Auth/Connect-GitHubAccount.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index b03ee34f6..7402b4223 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -157,8 +157,8 @@ Write-Verbose "Default ClientID: [$($script:Auth.$Mode.ClientID)]" $authClientID = $ClientID ?? (Get-GitHubConfig -Name 'AuthClientID') ?? $script:Auth.$Mode.ClientID Write-Verbose "Selected ClientID: [$authClientID]" - Write-Verbose "Using $Mode authentication..." if ($Mode -ne (Get-GitHubConfig -Name 'DeviceFlowType' -ErrorAction SilentlyContinue)) { + Write-Verbose "Using $Mode authentication..." $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -Scope $Scope -HostName $HostName } else { $accessTokenValidity = [datetime](Get-GitHubConfig -Name 'AccessTokenExpirationDate') - (Get-Date) From 90724984cae586c076df8e48600be63f5bf05032 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 7 Nov 2024 16:56:37 +0100 Subject: [PATCH 3/3] Fix login with UAT --- .../public/Auth/Connect-GitHubAccount.ps1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index 7402b4223..7d56614db 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -152,11 +152,16 @@ switch ($AuthType) { 'UAT' { Write-Verbose 'Logging in using device flow...' - Write-Verbose "Provided ClientID: [$ClientID]" - Write-Verbose "Stored ClientID: [$(Get-GitHubConfig -Name 'AuthClientID')]" - Write-Verbose "Default ClientID: [$($script:Auth.$Mode.ClientID)]" - $authClientID = $ClientID ?? (Get-GitHubConfig -Name 'AuthClientID') ?? $script:Auth.$Mode.ClientID - Write-Verbose "Selected ClientID: [$authClientID]" + if (-not [string]::IsNullOrEmpty($ClientID)) { + Write-Verbose "Using provided ClientID: [$ClientID]" + $authClientID = $ClientID + } elseif (-not [string]::IsNullOrEmpty($(Get-GitHubConfig -Name 'AuthClientID'))) { + Write-Verbose "Reusing previously stored ClientID: [$(Get-GitHubConfig -Name 'AuthClientID')]" + $authClientID = Get-GitHubConfig -Name 'AuthClientID' + } else { + Write-Verbose "Using default ClientID: [$($script:Auth.$Mode.ClientID)]" + $authClientID = $script:Auth.$Mode.ClientID + } if ($Mode -ne (Get-GitHubConfig -Name 'DeviceFlowType' -ErrorAction SilentlyContinue)) { Write-Verbose "Using $Mode authentication..." $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -Scope $Scope -HostName $HostName