I can't push to my repo. I just get 'invalid credentials'.
Asked by malik_rumi:

I am just now getting up to speed on the new security changes. I can log in through my browser, and I have created an app password, but all I get when trying to push is 'invalid credentials' over and over and over, no matter what password I put in there. I even tried my ssh key - same result. What am I supposed to do here?

edit / p.s. I suppose I could try changing my password / username on bitbucket.org, but frankly I'm leery that will just leave me locked out of everything, especially since the page I was offered \*only\* had a way to change the password, but \*not\* the username - which is an email address I thought we aren't supposed to be using anymore.


Answers:
author: Theodora Boudale
body: Hi [@malik_rumi](/t5/user/viewprofilepage/user-id/908139) ,

I would like to ask a few questions so I can better help you:

**1.** If you run **git remote -v** in your local clone, do you have an HTTPS URL or an SSH one right now?

If it is HTTPS, does it include your Bitbucket username as listed here? <https://bitbucket.org/account/settings/>

The email of your account should be used only for logging in to the Bitbucket website from the browser.  
The HTTPS URL of your repo should include your Bitbucket username instead of an email.

Does the remote URL of the repo have the following format?

```
https://BitbucketUsername@bitbucket.org/MyWorkspace/MyRepo.git
```

**2.** Do you use a command-line application to push to the repo, or a Git GUI client?

If you're using a Git GUI client, which one is it?

**3.** Can you run the following 3 commands from terminal (the last one in the directory of your clone)

```
git config --system credential.helper
git config --global credential.helper
git config --local credential.helper
```

and let me know if and what output you get from each of them?

It is possible that Git is using a credential helper that has a saved incorrect password/app password, which is used when you push.

**4.** Could you please post the full output you get from the push command? (Please make sure to sanitize any private info in the output prior to sharing)

Kind regards,  
Theodora

comments: author: malik_rumi
body: ```
$ git remote -v
    https

does it include your Bitbucket username?
    yes

Does the remote URL of the repo have the following format?
    https://BitbucketUsername@bitbucket.org/MyWorkspace/MyRepo.git

Not exactly. There is no camelcase, and the prefix to my user name is different. Further, I found
the whole project vs workspace terminology is confusing. They seem to be two different words for the
same thing. I have:
     https://bitbucket_cloud_username@bitbucket.org/MyWorkspace/MyRepo.git

2. Do you use a command-line application to push to the repo, or a Git GUI client?

I have a command line inside PyCharm. But PyCharm also has it's own vcs tools.

3. Can you run the following 3 commands from terminal (the last one in the directory of your clone)
Why just the last one? Where should the other 2 be run?

git config --system credential.helper
no output, just return to the $ prompt

git config --global credential.helper
same

git config --local credential.helper
same

4. Could you please post the full output you get from the push command? (Please make sure to sanitize any private info in the output prior to sharing)
(uscode) malikarumi@Tetuoan2:~/Projects/uscode$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

(uscode) malikarumi@Tetuoan2:~/Projects/uscode$ git push --set-upstream origin master
Password for 'https://bitbucket_cloud_username@bitbucket.org':
remote: Invalid credentials
fatal: Authentication failed for 'https://bitbucket.org/MyWorkspace/MyRepo.git/'


Note the password I presented is the 'new app password' generated the last time I was here, i.e., just before I posted this issue.
```


author: Theodora Boudale
body: Hi [@malik_rumi](/t5/user/viewprofilepage/user-id/908139),

Thank you for the info.

The remote url seems to have the correct format (I used camelcase simply for readability).

I would suggest trying the following so we can narrow down the cause of the issue:

**1.** If you try to make a new clone of the repo (for testing purposes) with

```
git clone https://bitbucket_cloud_username@bitbucket.org/MyWorkspace/MyRepo.git
```

Do you get asked for a password? If so, does the clone succeed if you provide the existing app password?

**2.** I see that you have several repositories in Bitbucket Cloud.

Are you able to clone and push changes to any of the other repos, with that same app password?

**3.** Can you create a new app password from <https://bitbucket.org/account/settings/app-passwords/>, make sure that it has **Repositories:Read** and **Repositories:Write** permissions, and let me know if you are able to push with the new app password?

**4.** Can you try changing the remote URL of your existing repo as follows:

```
git remote set-url origin https://bitbucket_cloud_username:app-password@bitbucket.org/MyWorkspace/MyRepo.git
```

where **app-password** replace with the value of your app password.

Are you able to push afterwards?

Please note that this command will save your app password in plain text in the config of the repo, so in case it works I would not recommend it as a permanent solution. I am suggesting this change temporarily only, for testing purposes.

Kind regards,  
Theodora


author: malik_rumi
body: 1. If you try to make a new clone of the repo (for testing purposes) with

git clone <https://bitbucket_cloud_username@bitbucket.org/MyWorkspace/MyRepo.git>

Do you get asked for a password? **No.**

If so, does the clone succeed if you provide the existing app password? **n/a**

*Result:* **No such file or directory**

2. I see that you have several repositories in Bitbucket Cloud.

Are you able to clone and push changes to any of the other repos, with that same app password?

*I didn't want to try it with this unresolved, but I did it, and yes, the one I tested did clone and did not ask for a password. Since that worked, I took note that the url given on the repo page in bitbucket to clone the repo is **NOT** in the form you gave me.*

*Therefore, I tried it with this new repo and putting that url in the same format as the test - which is not the form we've been using in this discussion:*

git clone git@bitbucket.org:username/repo.git

*note there is no /**project** / OR /**bitbucket_cloud_**/ portion of the url !!!*

*Since this worked, I have to assume the problem is that your documentation led us both to use the wrong url. I seem to be good to go. Thanks.*


author: Theodora Boudale
body: Hi [@malik_rumi](/t5/user/viewprofilepage/user-id/908139),

The URL git@bitbucket.org:workspace/repo.git is an SSH URL.

With Bitbucket Cloud, it is possible to use either the HTTPS protocol or the SSH protocol to clone/pull from/push to the remote repo. These are two different protocols and the remote URL used in each case is different.

If you want to use HTTPS, the remote URL should have the format I mentioned in my previous reply, and authentication will be done with a username and app password.

If you want to use SSH, then the format should be the one you mentioned in your last reply, and authentication will be done with the SSH key you set up for Bitbucket Cloud (there is no username and app password authentication in this case).

Since you have set up SSH keys for your Bitbucket Cloud account and SSH works for you, you can of course continue to work with that.

Kind regards,  
Theodora


author: Engineer
body: use ssh://git@bitbucket.org/ACCT/REPO.git

Make sure to add your identity (private key) to your local git via

git config --add --global core.sshCommand 'ssh -i \~/.ssh/id_ed25519'


Tags: bitbucket-cloud

cloud