che: GitHub authentication fails in VS Code if there is no PAT or if PAT has expired

Describe the bug

This error is presented to the user when VS Code tries to authenticate the user to GH:

Error: Invalid character in header content ["Authorization"]

Che version

next (development version)

Steps to reproduce

2 ways to reproduce it:

Cloning a repository from GitHub

  • Start an empty workspace
  • Open the command palette and select the command Git: Clone
  • Click “Clone from GitHub”

Using the GitHub Pull Request Plugin

Expected behavior

The user can sign in to GitHub and VS Code can use the GitHub API.

Runtime

OpenShift

Screenshots

image

image

Installation method

OperatorHub

Environment

Amazon

Eclipse Che Logs

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (13 by maintainers)

Most upvoted comments

@RomanNikitenko here is another video that I have just recorded on the dogfooding instance. Let me know what other information I can provide you to help you reproduce it:

https://user-images.githubusercontent.com/606959/229379176-4897cf6f-a06b-457c-9879-393b1bbf8387.mp4

We discussed briefly with @RomanNikitenko and we have decided to display an informative message to the user with the root cause of the problem and the instructions to fix it rather than implement the automatic update (that would probably require some work che-server side):

If the token has expired and is managed by Che

The GitHub token included in the workspace file '<token-path>' has expired. 
Restarting the workspace will automatically update the file with a new GitHub token.

If the token has expired but is NOT managed by Che

The GitHub token included in the workspace file '<token-path>' has expired. 
The expired token is stored in the secret <secret-name> and needs to be updated with a new one.

If the token is not present and the workspace is managed by Che

A valid GitHub token stored in file '<token-path>' is required for this feature to work.
Please reference to this [Eclipse Che documentation article](https://www.eclipse.org/che/docs/stable/end-user-guide/using-a-git-provider-access-token/) to learn how to automatically include one in your workspaces.

If the token is not present and the workspace is NOT managed by Che

A valid GitHub token stored in file '<token-path>' is required for this feature to work.
Please reference to this [DevWorkspace Operator documentation article](https://github.com/devfile/devworkspace-operator/blob/main/docs/additional-configuration.adoc#adding-git-credentials-to-a-workspace) to learn how to create a secret to automatically include one in your workspaces.