Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Unable to fetch private repo in composer using various methods

I have two private repos in Bitbucket.

  1. Repo One (User doesn't have access to this repo)
  2. Repo Two (User has write access to this repo)

Inside repo two, I am fetching Repo one as dependency

"repositories": [
{
"type": "vcs",
"url": "git@bitbucket.org:myproject/repo-one.git"
}
],
"require": {
"myproject/repo-one": "dev-dev"
}

I have created auth.json in the project root.

{
"config": {
"http-basic": {
"bitbucket.org": {
"username": "accessTokenEmail",
"password": "accessToken"
}
},
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "myKey",
"consumer-secret": "mySecret"
}
},
"bearer": {
"bitbucket.org": "accessToken"
}
}
}

I tried all three methods mentioned above but I am not able to fetch the private repo one.

I tried the above method individually in auth.json.

If I have access to both the repos then I am able to access the repo as a dependency in composer and that is normal.

I am using composer version as below

Composer version: 2.6.3

 

Am I doing anything wrong in this?

 

Thanks.

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 06, 2023

Hi Amit,

I'm not very familiar with composer, but if what composer does is clone the repo, then I see you are using an SSH URL for the repo:

git@bitbucket.org:myproject/repo-one.git

and the credentials you provide in the auth.json file are for authentication over HTTPS.

If you use an SSH URL, then authentication will be done with the SSH keys available on the machine where the repo is cloned. If these SSH keys are associated with a Bitbucket user account, it is expected that the account will need to have access to the repos.

 

If you don't need the user's SSH keys on this machine, you can remove them (please take a backup before you do) and then

  • generate a new SSH key pair on this machine
  • add the public key to the Access keys of the repos that need to be cloned (from Repository settings > Access keys). You need to have admin permission to the repo in order to add the Access keys.

 

If you want to use HTTPS, you'll need to provide an HTTPS URL for the repo, like this

https://bitbucket.org/myproject/repo-one.git

I'm not sure if the structure of your auth.json is correct, this is best to double-check in a composer-specific forum. However, if you are using a repository access token, then the username should be the string x-token-auth instead of an email.

 

If you are using an app password, then the username needs to be the username of the Bitbucket account you generated the app password for and it can be found here if it is your own account https://bitbucket.org/account/settings/.

 

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events