'Composer [UnexpectedValueException] Your github oauth token for github.com contains invalid characters:

Here i am. I already try few answers in StackOverFlow to fix this issue but it didn't work for me and i don't know what else can i do... So i want to install my project and every time i get this issue

enter image description here

  • I went to the file auth.json {"github-oauth": { "github.com": "ghp_uZfXyLME3qawVSyaZGRIhj3upFgaH24JYBn } }

and i took of the "github.com": "ghp_uZfXyLME3qawVSyaZGRIhj3upFgaH24JYBn" to get

{"github-oauth": { } }

  • I run composer self:update
  • I put back the line with the token
  • I try to install my app
  • And i get the same issue...

If somebody has anyidea how to fix it ?

I'm working actually with composer 2.1.6



Solution 1:[1]

You can try Basic Auth instead:

Change this (oauth):

"github-oauth": {
    "github.com": "ghp_[YOUR-PERSONAL-TOKEN]"
  }

To this (basic auth):

"http-basic": {
    "github.com": {
      "username": "[YOUR-GITHUB-USERNAME]",
      "password": "ghp_[YOUR-PERSONAL-TOKEN]"
    }
  }

Solution 2:[2]

Solved!

This worked by using:

export COMPOSER_AUTH="{\"http-basic\": {\"github.com\": {\"username\":\"github_username\",\"password\":\"github_token\"}}}"

Note: Replace (github_username/github_token) by your own credentials

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Md. Jamil Ahsan
Solution 2 MiraTech