1

Got "UnexpectedValueException" Your github oauth token for github.com contains invalid characters:"" while composer update on yii2 project.

When i was installing jui datetimepicker via composer, I have asked to give git token to install it. I had generated the token from GitLab and provide the token to terminal.I also change the composer.json file with token. But it gives me an error of "UnexpectedValueException" Your github oauth token for github.com contains invalid characters.

I have tried following solutions : 1) I have deleted my .git folder and tried to update composer still same issue

2) I have deleted the vendor and reinstall the composer not worked.

3) I have deleted the vendor and composer.json and put the previous vendor and composer.json file from my backup. but still get same issue.

4) I have tried to change the token from the following code :

composer config --global github-oauth.github.com <TOKEN>

5) Also put the following code in composer.json :

{  
  "config": {
    "github-oauth": {
      "github.com": "<TOKEN>"
      }
    }
} 

Still same issue.

My composer.json file is as follows :

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Application Template",
    "keywords": ["yii2", "framework", "advanced", "application template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "claudejanz/yii2-mygii": "dev-master",
        "bower-asset/jquery": "@stable",
        "bower-asset/jquery.inputmask": "@stable",
        "bower-asset/punycode": "@stable",
        "bower-asset/bootstrap": "@stable",
        "3ch3r46/bootui-datepicker": "1.0.0",
        "yiisoft/yii2-jui": "*",
        "udokmeci/yii2-phone-validator" : "dev-master"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*"
    },
    "suggest": {
        "codeception/codeception": "Codeception, 2.0.* is currently works well with Yii.",
        "codeception/specify": "BDD style code blocks for PHPUnit and Codeception",
        "codeception/verify": "BDD Assertions for PHPUnit and Codeception",
        "yiisoft/yii2-faker": "Fixtures generator for Yii2 based on Faker lib"
    },
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::setPermission"
        ]
    },
    "config": {
        "process-timeout": 1800
    },
    "extra": {
        "writable": [
            "backend/runtime",
            "backend/web/assets",
            "frontend/runtime",
            "frontend/web/assets"
        ],
        "executable": [
            "yii"
        ],
        "asset-installer-paths":    {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    },
    "repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
]
}

Please someone help.

php guy
  • 113
  • 13
  • Github auth token is usually stored in `~/.composer/auth.json` (for Linux) - have you checked that one? – Bizley May 10 '19 at 07:36
  • Where can i get this file in linux? – php guy May 10 '19 at 08:17
  • I've gave you path. It of course depends on the composer global installation path but usually it's your home folder. – Bizley May 10 '19 at 08:24
  • i can not locate this file.Please suggest how i can locate it? – php guy May 10 '19 at 08:48
  • Try `composer config -g data-dir`. If it doesn't work look at docs at getcomposer.org – Bizley May 10 '19 at 09:09
  • Thank you so much for your help. I have found auth.json file and changed the token there. Now my composer working fine. Thanks so much again. please answer the question i will accept it. – php guy May 10 '19 at 09:25

1 Answers1

1

I'm not sure what was the reason why it stopped working for you but as we discussed in comments the solution was to update the entry in auth.json that stores this GitHub token.

For everyone looking for this solution - auth.json is stored in your COMPOSER_HOME path. You can find this path by calling in the console

composer config -g data-dir

For more information about Composer configuration please refer to the Composer documentation at getcomposer.org.

Bizley
  • 17,392
  • 5
  • 49
  • 59
  • After this i can not commit in gitlab. giving error like "fatal: Unable to create '/var/www/html/project/.git/index.lock': Permission denied" I think my token has no rights to add and commit in gitlab. Can you tell me where i can create all access permitted token? – php guy May 10 '19 at 09:43
  • I am using Gitlab – php guy May 10 '19 at 09:50
  • Sorry, don't know where to check active tokens there. I'm sure it's easy to find in account settings though. – Bizley May 10 '19 at 09:54
  • I started getting a similar error and the reason was that github recently changed their auth token and we need to update composer to its latest version. Left more details here: https://stackoverflow.com/questions/26691681/composer-unexpectedvalueexception-error-will-trying-to-use-composer-to-install/67005141#67005141 – rafaelbiten Apr 08 '21 at 13:38