Loading
chore: slightly improve logging of failed OAuth flow
Description
Small fix to catch an error during the createOAuthAccountFromCode() call.
Before
2024-03-04T14:33:29:329 [debug]: fetch: request to https://gitlab.steveazz.xyz/oauth/token returned HTTP 401 after 354 ms
After
2024-03-04T14:24:41:413 [debug]: fetch: request to https://gitlab.steveazz.xyz/oauth/token returned HTTP 401 after 354 ms
2024-03-04T14:24:41:424 [error]: OAuth flow: Creating account from code failed:
{
"message": "Fetching refresh token from https://gitlab.steveazz.xyz/oauth/token failed",
"stack": [
"Error: Fetching refresh token from https://gitlab.steveazz.xyz/oauth/token failed",
" at handleFetchError (/Users/tomas/workspace/gl/gitlab-vscode-extension/src/common/errors/handle_fetch_error.ts:6:11)",
" at processTicksAndRejections (node:internal/process/task_queues:95:5)",
" at Function.exchangeToken (/Users/tomas/workspace/gl/gitlab-vscode-extension/src/desktop/gitlab/gitlab_service.ts:959:5)",
" at TokenExchangeService.createOAuthAccountFromCode (/Users/tomas/workspace/gl/gitlab-vscode-extension/src/desktop/gitlab/token_exchange_service.ts:55:27)",
" at /Users/tomas/workspace/gl/gitlab-vscode-extension/src/desktop/accounts/oauth/gitlab_authentication_provider.ts:170:25"
],
"response": {
"status": 401,
"headers": {},
"body": "{\"error\":\"invalid_client\",\"error_description\":\"Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.\"}"
}
}
Related Issues
I found this during cells testing gitlab#434977 (closed)
How has this been tested?
-
Checkout this branch
-
Apply this patch
diff --git a/src/common/constants.ts b/src/common/constants.ts index 8b241395..e8a65120 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -1,4 +1,4 @@ -export const GITLAB_COM_URL = 'https://gitlab.com'; +export const GITLAB_COM_URL = 'https://gitlab.steveazz.xyz'; export const CONFIG_NAMESPACE = 'gitlab'; export const DO_NOT_SHOW_CODE_SUGGESTIONS_VERSION_WARNING = 'DO_NOT_SHOW_VERSION_WARNING'; diff --git a/src/desktop/constants.ts b/src/desktop/constants.ts index dcfe1bbd..e91ce754 100644 --- a/src/desktop/constants.ts +++ b/src/desktop/constants.ts @@ -22,7 +22,7 @@ export const HAS_COMMENTS_QUERY_KEY = 'hasComments'; export const PATCH_TITLE_PREFIX = 'patch: '; export const PATCH_FILE_SUFFIX = '.patch'; -export const OAUTH_CLIENT_ID = '36f2a70cddeb5a0889d4fd8295c241b7e9848e89cf9e599d0eed2d8e5350fbf5'; +export const OAUTH_CLIENT_ID = 'b5fc2cf2ef81505a646e0cd87a9d56ef6c35f38910a15fa2e2f32b7a779aebf4'; export const OAUTH_REDIRECT_URI = `${vscode.env.uriScheme}://gitlab.gitlab-workflow/authentication`; /** Synced comment is stored in the GitLab instance */ diff --git a/src/desktop/gitlab/gitlab_service.ts b/src/desktop/gitlab/gitlab_service.ts index 0cc4db27..377c3f7f 100644 --- a/src/desktop/gitlab/gitlab_service.ts +++ b/src/desktop/gitlab/gitlab_service.ts @@ -949,6 +949,10 @@ export class GitLabService { params.grantType === 'authorization_code' ? [`code=${params.code}`, `code_verifier=${params.codeVerifier}`] : [`refresh_token=${params.refreshToken}`]; + console.log( + `${params.instanceUrl}/oauth/token`, + [...commonParams, ...grantTypeParams].join('&'), + ); const response = await apiClient.crossFetch(`${params.instanceUrl}/oauth/token`, { method: 'POST', headers: { -
Log in to cells (https://gitlab.steveazz.xyz/users/sign_in), use
rootuser, passwords is in 1Password vault -
Run "authenticate to GitLab.com" command
-
See the better logging