composer / composer

Dependency Manager for PHP
https://getcomposer.org/
MIT License
28.67k stars 4.56k forks source link

Composer install issue Cannot authenticate with bitbucket repository #11898

Closed manjeetsinghcodz closed 2 months ago

manjeetsinghcodz commented 8 months ago

I'm having an issue with composer install while authenticating with bitbucket via oauth.

Composer running on a linux mint 21 PC composer -V

Composer version 2.7.2 2024-03-11 17:12:18
PHP version 8.1.2-1ubuntu2.14 (/usr/bin/php8.1)

My composer.json:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "theme/flatsome-child",
                "version": "1.0",
                "type": "wordpress-theme",
                "source": {
                    "url": "https://myuserid@bitbucket.org/myworkspace/theme-child.git",
                    "type": "git",
                    "reference": "master"
                },
                "require": {
                    "composer/installers": "~1.0"
                } 
            }

        },
        {
            "type": "package",
            "package": {
                "name": "theme/flatsome",
                "version": "1.0",
                "type": "wordpress-theme",
                "source": {
                    "url": "https://myuserid@bitbucket.org/myworkspace/theme.git",
                    "type": "git",
                    "reference": "master"
                },
                "require": {
                    "composer/installers": "~1.0"
                } 
            }

        },
        {
            "type": "package",
            "package": {
                "name": "plugin/redis-cache",
                "version": "1.0",
                "type": "wordpress-plugin",
                "source": {
                    "url": "https://myuserid@bitbucket.org/myworkspace/plugin-redis.git",
                    "type": "git",
                    "reference": "master"
                },
                "require": {
                    "composer/installers": "~1.0"
                } 
            }

        },
        {
            "type": "package",
            "package": {
                "name": "plugin/mod_wordpress_magiczoom",
                "version": "1.0",
                "type": "wordpress-plugin",
                "source": {
                    "url": "https://myuserid@bitbucket.org/myworkspace/mod_magiczoom_wp.git",
                    "type": "git",
                    "reference": "master"
                },
                "require": {
                    "composer/installers": "~1.0"
                } 
            }

        },
        {
            "type": "package",
            "package": {
                "name": "plugin/mod_woocommerce_magiczoom",
                "version": "1.0",
                "type": "wordpress-plugin",
                "source": {
                    "url": "https://myuserid@bitbucket.org/myworkspace/mod_magiczoom_woo.git",
                    "type": "git",
                    "reference": "master"
                },
                "require": {
                    "composer/installers": "~1.0"
                } 
            }

        },
        {
            "type": "package",
            "package": {
                "name": "plugin/mod_wordpress_magicscroll",
                "version": "1.0",
                "type": "wordpress-plugin",
                "source": {
                    "url": "https://myuserid@bitbucket.org/myworkspace/mod_magicscroll_wp.git",
                    "type": "git",
                    "reference": "master"
                },
                "require": {
                    "composer/installers": "~1.0"
                } 
            }

        },
        {
            "type":"composer",
            "url":"https://wpackagist.org",
            "only": [
                "wpackagist-plugin/*",
                "wpackagist-theme/*"
            ]
        },
        {
            "type": "package",
            "package": {
                "type": "webroot",
                "name": "base/core",
                "version": "6.4.3",
                "dist": {
                    "url": "https://github.com/WordPress/WordPress/archive/refs/tags/6.4.3.zip",
                    "type": "zip"
                },
                "require": {
                    "fancyguy/webroot-installer": "1.0.0"

                }
            }
        }

    ],

    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "base/core": "6.4.3",
        "theme/flatsome-child": "^1.0",
        "theme/flatsome": "^1.0",
        "wpackagist-plugin/woocommerce": "^5.7",
        "wpackagist-plugin/contact-form-7": "^5.4",
        "wpackagist-plugin/facebook-for-woocommerce": "^2.6",
        "wpackagist-plugin/woocommerce-admin": "^2.6",
        "wpackagist-plugin/woosidebars": "^1.4",
        "wpackagist-plugin/yith-woocommerce-wishlist": "^3.1",
        "wpackagist-plugin/wp-mail-smtp":"3.0.3",
        "plugin/redis-cache": "^1.0",
        "plugin/mod_wordpress_magiczoom": "^1.0",
        "plugin/mod_woocommerce_magiczoom": "^1.0",
        "plugin/mod_wordpress_magicscroll": "^1.0"
    },

    "extra": {
        "webroot-dir": "base",
        "webroot-package": "base/core"
    },
    "config": {
        "allow-plugins": {
            "fancyguy/webroot-installer": true,
            "composer/installers": true
        }
    }
}

Output of composer diagnose: rm -rf composer.lock wp-content vendor ; composer clearcache ; composer install


Cache directory does not exist (cache-vcs-dir): 
Clearing cache (cache-repo-dir): /home/user/.cache/composer/repo
Cache directory does not exist (cache-files-dir): 
Clearing cache (cache-dir): /home/user/.cache/composer
All caches cleared.
Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Lock file operations: 16 installs, 0 updates, 0 removals
  - Locking base/core (6.4.3)
  - Locking composer/installers (v1.12.0)
  - Locking fancyguy/webroot-installer (1.0.0)
  - Locking plugin/mod_woocommerce_magiczoom (1.0)
  - Locking plugin/mod_wordpress_magicscroll (1.0)
  - Locking plugin/mod_wordpress_magiczoom (1.0)
  - Locking plugin/redis-cache (1.0)
  - Locking theme/flatsome (1.0)
  - Locking theme/flatsome-child (1.0)
  - Locking wpackagist-plugin/contact-form-7 (5.9.2)
  - Locking wpackagist-plugin/facebook-for-woocommerce (2.6.30)
  - Locking wpackagist-plugin/woocommerce (5.9.1)
  - Locking wpackagist-plugin/woocommerce-admin (2.9.4)
  - Locking wpackagist-plugin/woosidebars (1.4.6)
  - Locking wpackagist-plugin/wp-mail-smtp (3.0.3)
  - Locking wpackagist-plugin/yith-woocommerce-wishlist (3.31.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 16 installs, 0 updates, 0 removals
  - Downloading fancyguy/webroot-installer (1.0.0)
  - Downloading composer/installers (v1.12.0)
  - Downloading base/core (6.4.3)
  - Syncing plugin/mod_woocommerce_magiczoom (1.0) into cache

In Git.php line 473:

  Failed to execute git clone --mirror -- 'https://z4S...tZv:hys...xWY@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-moris  
  gifts-mod-magiczoom-woo.git/'                                                                                                                                                             

  Cloning into bare repository '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git'...                                                           
  remote: Invalid credentials                                                                                                                                                               
  fatal: Authentication failed for 'https://bitbucket.org/myworkspace/mod_magiczoom_woo.git/'                                                                                                

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

When I run this command composer install -vvv

Running 2.7.2 (2024-03-11 17:12:18) with PHP 8.1.2-1ubuntu2.14 on Linux / 5.15.0-101-generic
Reading ./composer.json (/home/user/Documents/Projects/ecom/base/composer.json)
Loading config file /home/user/.config/composer/auth.json
Loading config file ./composer.json (/home/user/Documents/Projects/ecom/base/composer.json)
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/home/user/Documents/Projects/ecom/base): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Reading /home/user/.config/composer/composer.json
Loading config file /home/user/.config/composer/auth.json
Loading config file /home/user/.config/composer/composer.json (/home/user/.config/composer/composer.json)
Loading config file /home/user/.config/composer/auth.json
Reading /home/user/.config/composer/auth.json
Reading ./composer.lock (/home/user/Documents/Projects/ecom/base/composer.lock)
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Reading ./composer.lock (/home/user/Documents/Projects/ecom/base/composer.lock)
Built pool.
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Package operations: 16 installs, 0 updates, 0 removals
Installs: fancyguy/webroot-installer:1.0.0, composer/installers:v1.12.0, base/core:6.4.3, plugin/mod_woocommerce_magiczoom:1.0, plugin/mod_wordpress_magicscroll:1.0, plugin/mod_wordpress_magiczoom:1.0, plugin/redis-cache:1.0, theme/flatsome:1.0, theme/flatsome-child:1.0, wpackagist-plugin/contact-form-7:5.9.2, wpackagist-plugin/facebook-for-woocommerce:2.6.30, wpackagist-plugin/woocommerce:5.9.1, wpackagist-plugin/woocommerce-admin:2.9.4, wpackagist-plugin/woosidebars:1.4.6, wpackagist-plugin/wp-mail-smtp:3.0.3, wpackagist-plugin/yith-woocommerce-wishlist:3.31.0
Reading /home/user/.cache/composer/files/fancyguy/webroot-installer/90b9bf7073aa24ba7912d5d74e8b53c4c84bce6c.zip from cache
  - Loading fancyguy/webroot-installer (1.0.0) from cache
Reading /home/user/.cache/composer/files/composer/installers/e96bad3e86bc0d257802a8b50035d47cac50c0e7.zip from cache
  - Loading composer/installers (v1.12.0) from cache
Reading /home/user/.cache/composer/files/base/core/53f78cd70b23f7fd3a2a9486bf4e34ff94477138.zip from cache
  - Loading base/core (6.4.3) from cache
Executing command (CWD): git --version
  - Syncing plugin/mod_woocommerce_magiczoom (1.0) into cache
    Cloning to cache at '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git/'
Executing command (CWD): git clone --mirror -- 'https://userid@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git/'
Executing command (CWD): git clone --mirror -- 'https://z4SRfSYGetQ5TSFtZv:***@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git/'
Executing command (CWD): git --version
Failed: [RuntimeException] Failed to execute git clone --mirror -- 'https://z4S...tZv:hys...xWY@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git/'

Cloning into bare repository '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git'...
remote: Invalid credentials
fatal: Authentication failed for 'https://bitbucket.org/myworkspace/mod_magiczoom_woo.git/'

In Git.php line 473:

  [RuntimeException]                                                                                                                                                                        
  Failed to execute git clone --mirror -- 'https://z4S...tZv:hys...xWY@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-moris  
  gifts-mod-magiczoom-woo.git/'                                                                                                                                                             

  Cloning into bare repository '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git'...                                                           
  remote: Invalid credentials                                                                                                                                                               
  fatal: Authentication failed for 'https://bitbucket.org/myworkspace/mod_magiczoom_woo.git/'                                                                                                

Exception trace:
  at phar:///usr/bin/composer/src/Composer/Util/Git.php:473
 Composer\Util\Git->throwException() at phar:///usr/bin/composer/src/Composer/Util/Git.php:259
 Composer\Util\Git->runCommand() at phar:///usr/bin/composer/src/Composer/Util/Git.php:296
 Composer\Util\Git->syncMirror() at phar:///usr/bin/composer/src/Composer/Util/Git.php:329
 Composer\Util\Git->fetchRefOrSyncMirror() at phar:///usr/bin/composer/src/Composer/Downloader/GitDownloader.php:78
 Composer\Downloader\GitDownloader->doDownload() at phar:///usr/bin/composer/src/Composer/Downloader/VcsDownloader.php:73
 Composer\Downloader\VcsDownloader->download() at phar:///usr/bin/composer/src/Composer/Downloader/DownloadManager.php:223
 Composer\Downloader\DownloadManager->Composer\Downloader\{closure}() at phar:///usr/bin/composer/src/Composer/Downloader/DownloadManager.php:235
 Composer\Downloader\DownloadManager->download() at phar:///usr/bin/composer/src/Composer/Installer/LibraryInstaller.php:114
 Composer\Installer\LibraryInstaller->download() at phar:///usr/bin/composer/src/Composer/Installer/InstallationManager.php:277
 Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/bin/composer/src/Composer/Installer/InstallationManager.php:218
 Composer\Installer\InstallationManager->execute() at phar:///usr/bin/composer/src/Composer/Installer.php:821
 Composer\Installer->doInstall() at phar:///usr/bin/composer/src/Composer/Installer.php:294
 Composer\Installer->run() at phar:///usr/bin/composer/src/Composer/Command/InstallCommand.php:147
 Composer\Command\InstallCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:385
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:145
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:93
 require() at /usr/bin/composer:29

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

My auth.json file is /home/user/.config/composer/auth.json.

My first attempt : I confirm i did below on bitbucket

ticked This is a private consumer
updated my Callback URL 
given read permission
**Auth.json file**
{
    "bitbucket-oauth": {
        "bitbucket.org": {
            "consumer-key": "key",
            "consumer-secret": "secret"
        }
    }
}

Second attempt :

curl -X POST -u "key:secret" https://bitbucket.org/site/oauth2/access_token -d grant_type=client_credentials
{"access_token": "g2FaNfnBNcyJmdwiOlpmbvgaXjxfX9Gxg8zHW7DzSmwjnM_4VSqImKnHYZRuecOuQvxJ63ypKxTLMsdnvg5H0HjwhyaAMuWdPl7nzuuM-X4hWJP2YzlwI9ofAQx1KEjxDuUeaPqM6sXBEv2Z2N7z1C3QXbR7", "scopes": "snippet pullrequest team runner project account pipeline webhook issue", "token_type": "bearer", "expires_in": 7200, "state": "client_credentials", "refresh_token": "wufQ6s5K7ZGuXTT4VD"

Updated my auth.json :

{
    "bitbucket-oauth": {
        "bitbucket.org": {
            "consumer-key": "key",
            "consumer-secret": "secret",
            "access-token": ""g2FaNfnBNcyJmdwiOlpmbvgaXjxfX9Gxg8zHW7DzSmwjnM_4VSqImKnHYZRuecOuQvxJ63ypKxTLMsdnvg5H0HjwhyaAMuWdPl7nzuuM-X4hWJP2YzlwI9ofAQx1KEjxDuUeaPqM6sXBEv2Z2N7z1C3QXbR7",
            "access-token-expiration": 7200
        }
    }

Got the same error

Failed: [RuntimeException] Failed to execute git clone --mirror -- 'https://z4S...tZv:hys...xWY@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git/'

Cloning into bare repository '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git'...
remote: Invalid credentials
fatal: Authentication failed for 'https://bitbucket.org/myworkspace/mod_magiczoom_woo.git/'

In Git.php line 473:

  [RuntimeException]                                                                                                                                                                        
  Failed to execute git clone --mirror -- 'https://z4S...tZv:hys...xWY@bitbucket.org/myworkspace/mod_magiczoom_woo.git' '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-moris  
  gifts-mod-magiczoom-woo.git/'                                                                                                                                                             

  Cloning into bare repository '/home/user/.cache/composer/vcs/https---userid-bitbucket.org-myworkspace-mod-magiczoom-woo.git'...                                                           
  remote: Invalid credentials                                                                                                                                                               
  fatal: Authentication failed for 'https://bitbucket.org/myworkspace/mod_magiczoom_woo.git/'                                                                                                

Exception trace:
  at phar:///usr/bin/composer/src/Composer/Util/Git.php:473
 Composer\Util\Git->throwException() at phar:///usr/bin/composer/src/Composer/Util/Git.php:259
 Composer\Util\Git->runCommand() at phar:///usr/bin/composer/src/Composer/Util/Git.php:296
 Composer\Util\Git->syncMirror() at phar:///usr/bin/composer/src/Composer/Util/Git.php:329
 Composer\Util\Git->fetchRefOrSyncMirror() at phar:///usr/bin/composer/src/Composer/Downloader/GitDownloader.php:78
 Composer\Downloader\GitDownloader->doDownload() at phar:///usr/bin/composer/src/Composer/Downloader/VcsDownloader.php:73
 Composer\Downloader\VcsDownloader->download() at phar:///usr/bin/composer/src/Composer/Downloader/DownloadManager.php:223
 Composer\Downloader\DownloadManager->Composer\Downloader\{closure}() at phar:///usr/bin/composer/src/Composer/Downloader/DownloadManager.php:235
 Composer\Downloader\DownloadManager->download() at phar:///usr/bin/composer/src/Composer/Installer/LibraryInstaller.php:114
 Composer\Installer\LibraryInstaller->download() at phar:///usr/bin/composer/src/Composer/Installer/InstallationManager.php:277
 Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/bin/composer/src/Composer/Installer/InstallationManager.php:218
 Composer\Installer\InstallationManager->execute() at phar:///usr/bin/composer/src/Composer/Installer.php:821
 Composer\Installer->doInstall() at phar:///usr/bin/composer/src/Composer/Installer.php:294
 Composer\Installer->run() at phar:///usr/bin/composer/src/Composer/Command/InstallCommand.php:147
 Composer\Command\InstallCommand->execute() at phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:301
 Symfony\Component\Console\Application->doRun() at phar:///usr/bin/composer/src/Composer/Console/Application.php:385
 Composer\Console\Application->doRun() at phar:///usr/bin/composer/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///usr/bin/composer/src/Composer/Console/Application.php:145
 Composer\Console\Application->run() at phar:///usr/bin/composer/bin/composer:93
 require() at /usr/bin/composer:29

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

Please help. Thank u very much

github-actions[bot] commented 2 months ago

This issue has been automatically marked Stale and will be closed in 15 days if no further activity happens.