29

While pushing a commit to GitHub yesterday, I received an email from the GitHub team:

Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.

Thanks, The GitHub Team

I don't understand a word of the help page... I did create a more secure access token a few months ago when they first announced the change in authentification, and entered it in the terminal of my mac. I thought that would be it. My question is: how to update an Rstudio session created when token weren't necessary to match the new access-token policy?

Thanks in advance for your help,
Rosalie

Rosalie Bruel
  • 1,423
  • 1
  • 10
  • 22

3 Answers3

50

I don't know how to validate user @r2evans' comment above, but indeed it worked! I already had a PAT token set, so I followed the steps in https://happygitwithr.com/credential-caching.html#credential-caching, starting at 10.2.1.1

install.packages("gitcreds")
library(gitcreds)
gitcreds_set()

I had to enter my account password (computer password), then it showed my current identification parameters. In the console, three choices appear:

1: Keep these credentials
2: Replace these credentials
3: See the password / token

Select 2 to replace the password/token (credentials), and voilà!

Thanks for the easy fix @r2evans.

Rosalie Bruel
  • 1,423
  • 1
  • 10
  • 22
  • This worked! It was enough to run gitcreds_set() and insert token, and problem was solved. It should be noted that when prompted for password/token you must add a token. You may have to make the token first. To make a token, see ths recipe: https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token – madsR Sep 15 '21 at 19:55
  • And (note to future self), the token should not be in quotes! – p0bs Jan 30 '22 at 16:32
11

@r2evans this was very helpful!

For future visitors of this thread, running gitcreds_set() will prompt a dialog in Rstudio that will ask you what you would like to do with your previous existing user/password credentials.

1: Keep these credentials
2: Replace these credentials
3: See the password / token

By opting for 2, I replaced my credentials with an existing token that I already created on Github. It worked seamlessly!

Sharon
  • 311
  • 2
  • 5
6

The solutions above didn't work for me. I had to use:

credentials::set_github_pat("my_pat")

Then when prompted by the pop-up boxes I had to use my PAT as my password.

Bryan Shalloway
  • 748
  • 7
  • 15