0

I have an existing GitHub account. I am working in bash shell and Visual Studio code on a MacBook Air. I made a new Directory in bash and added two files (a README.md and script.js) as I am learning Javascript and creating a random message generator application. I did a 'git init' to initialize the local repository, then went to GitHub to make a (new) remote repository. GitHub is asking for my password, even though now passwords are deprecated and they are now requiring a long token. But when I enter my token I get:

Jeanines-Air:message_generator jeanineloughlin$ git push -u origin main
Password for 'https://github-jalcoding8@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github-jalcoding8@github.com/github-jalcoding8/github-message_generator.git/'

At first I was asked to enter both username/password. Now it's just password. Prior to the change from password to token, I was never asked to enter my username/password. Can someone suggest a solution. Should I use the cache option in GitHub?

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • Try deleting the GitHub password saved in your keychain, so that it prompts you to log in again when you do a git interaction with the remote. And then give your token when it asks for a password. I think you can also replace the keychain value with a token too (alt solution). – JBallin Oct 16 '21 at 22:30
  • I hesitate to do that as I am concerned that I will be locked out of my GitHub account if it doesn't work. I am not receiving an error that my token (as password) is incorrect, it's simply not functional, if that makes sense. I'm using https: so I though using the caching GitHub option might work. And when I look in my GitHub repos the repository I just created is there. I just can't push from local to remote. – more_to_learn Oct 16 '21 at 22:38
  • Does this answer your question? [Support for password authentication was removed. Please use a personal access token instead](https://stackoverflow.com/questions/68775869/support-for-password-authentication-was-removed-please-use-a-personal-access-to) – bk2204 Oct 16 '21 at 22:47
  • I am using a personal token. – more_to_learn Oct 16 '21 at 22:57

1 Answers1

0

To be clear, you're being asked for a password because the password dialog comes from the Git client. Github's Git esrver decides that your password is your personal access token, and their server is also generating the error message.

You will get the same message if you give an incorrect password/token. Double check your token is correct and has not expired. To be sure, create a fresh token and delete the old one.

Better yet, use SSH keys.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • So, I used that URL because I was looking through stack overflow before I posted my question. Before I implemented that URL GitHub was asking for both my username and password. After just my password (Someone on SO suggested that). But that, of course, did nothing. Because the issue is that GitHub is not accepting the access token I enter when prompted for my password. – more_to_learn Oct 16 '21 at 23:30
  • @more_to_learn Yes, my answer was a red herring. It works with or without the username. Are you sure your access token is correct? I get the same response for an incorrect token. And are you sure it has not expired? Try generating a new token. – Schwern Oct 17 '21 at 19:34
  • Yes, my access token is active (it does not expire until November 12) I purposely entered the access token incorrectly to check if it generated an "incorrect password" and it did. So I have entered a correct, active access token. Then I did a git config --list to see that everything else is in order. I'm not familiar with SSH key protocol, but I did check and in git entered ls -al ~/.ssh to see there are already some ssh in use, but don't know what to do with that information. – more_to_learn Oct 19 '21 at 00:15
  • @more_to_learn Sorry, the best explanation is that you're using the wrong token. If you haven't already, try generating a new token and use that. Are you sure it's the personal access token *for that account*? Instead of HTTPS, SSH is an alternate way to interact with remote repositories. Github's help guide is linked in the answer. – Schwern Oct 19 '21 at 00:23
  • Sooo, this happened. – more_to_learn Oct 19 '21 at 16:56
  • For the benefit of anyone who might encounter this issue. When i created my GitHub account I also created a new gmail account as well. So that new email would be associated with all things GitHub related. But I also have another gmail account. – more_to_learn Oct 19 '21 at 17:14
  • To Schwern: Thank you for your help. I went on the assumption that perhaps I am using the wrong access token even though it was newly generated for this project. So I deleted it. Then I created a new authentication access token. Then I went back to working on my project. I started over and deleted the local repository in bash, as well as in GitHub remote repository. So I made a new directory using git commands in bash shell, and added 2 empty files (git touch). Then I did a 'git init' to initialize the local repository. Then I went over to GitHub to make the remote repository. – more_to_learn Oct 19 '21 at 17:15
  • Next, I used the second option on Github that has three commands: And entered them in bash 1). git remote add origin https://github.com/your-github-username-here/name-of-directory-here.git 2). git branch -M main, and 3). git push -u origin main. Then I was prompted in bash to enter my GitHub username. Next I was prompted to enter my 'password' BUT NOW this is the authentication access token which I copied when I made it (in GitHub). But then in the upper right corner of my MacBook I saw a text box from Google telling me I needed to log into my gmail to for the authentication, – more_to_learn Oct 19 '21 at 17:16
  • however it was pointing to the other gmail account, not my associated GitHub gmail account. This was the first time this happened. I took the chance to cancel, rather than continue. And then I went back to bash and when I entered: the 3rd GitHub command 'git push -u origin main' and entered my GitHub username and brand new access token I was finally able to push my local repository to the remote GitHub repository. Sorry for the length of data but this issue has been mentioned before, but not specific to my problem. Thank you again Schwern. – more_to_learn Oct 19 '21 at 17:20
  • @more_to_learn **tl;dr** You were using the token from a different account? – Schwern Oct 19 '21 at 17:29
  • No. my GitHub is only linked to the one gmail. My other gmail is not. After I deleted the previous access token, created a new token and used it to push my local repository to the remote GitHub repo, I noticed that I had been sent an email to the gmail I created for my GitHub account, same as with the first token, an email confirmation. So I'm still baffled as to why the second token worked when the first did not. But I am relieved that it works. – more_to_learn Oct 20 '21 at 01:04