I have oauth2 access_token for user with scope repo which means I can basically access all public/private repos of the user.
I have a local copy of a repo on my machine and I want to pull (fetch and merge) using the authenticated user's token in github api.
How do I manage this?
An OAuth access token, (like PAT (Personal Access Token)) can be used from command-line:
That OAuth token can be used as a password when GitHub asks for your credentials (username/password) for an HTTPS URL.
Therefore, make sure the remote URL is an HTTPS one, with <theuser>
username in it
cd /path/to/repo
git remote -v
# if origin starts with git@github.com (SSH)
git remote set-url origin https://<theuser>@github.com/<theuser>/<repo>
Whenever you clone/pull/push a private repo from <theuser>
, enter the OAuth access token as a password.
Or check your git config credential.helper
: you can cache those credentials, using for instance the GCM (Git Credential Manager) like one for Mac/Linux, or for Windows.
Note that git merge
is a local-only operation, so it won't require any credentials.