Home > OS >  Pushing to Github using Personal Access Token not working
Pushing to Github using Personal Access Token not working

Time:06-15

I have been attempting to push to gh using a generated personal access token from my shell terminal. It worked only once after I spammed git --set-upstream origin push master but it's not pushing commits anymore. I can still clone repos.

I have also edited the git config file but it keeps asking for a password. Whenever I use the token, it throws this error:

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.com/kurosakiaduma/alx-pre_course.git/'

Here are my remotes:

origin  https://kurosakiaduma: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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@github.com/kurosakiaduma/alx-pre_course.git (fetch)
origin  https://kurosakiaduma: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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@github.com/kurosakiaduma/alx-pre_course.git (push)

Where could I have gone wrong?

CodePudding user response:

Check first your git config --global credential.helper value.

If it is xxx (like 'manager' or 'manager-core'), check what is stored for github.com

printf "host=github.com\nprotocol=https" | git credential-xxx get
printf "host=github.com\nprotocol=https\nusername=kurosakiaduma" | git credential-xxx get

(replace xxx by the value returned by git config --global credential.helper)

That way, you will know if a password (instead of a token) was stored/ cached in the credential helper.

If the wrong value is stored, you can overwrite it with:

printf "host=github.com\nprotocol=https\nusername=kurosakiaduma\npassword=ghp_yourToken" | git credential-xxx store
  • Related