I implemented the oauth2 web flow in order to get access_token from users of my app. With the access_token, I would like to do the following actions:
I already successfully get the user information(1) and create a repo(2)
The problem is I can't push code (3), I got "Unauthorized" error.
The command I run:
git remote add origin https://gitlab-ci-token<mytoken>@gitlab.com/myuser/myrepo.git
git push origin master
You should do
git remote add origin https://<access-token-name>:<access-token>@gitlab.com/myuser/myrepo.git
Note that this stores the access token as plain text in the .git\config
file. To avoid this you can use the git credential system, providing the access token name for "username" and the access token for "password". This should store the credentials in the git credential system in a more secure way.