Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Username and password authentication #1694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
krupis opened this issue Oct 4, 2023 · 0 comments
Closed

Username and password authentication #1694

krupis opened this issue Oct 4, 2023 · 0 comments

Comments

@krupis
Copy link

krupis commented Oct 4, 2023

Hello. I recently came across this library for git on Python. I am working on a project where client needs to have a script which he can run to fetch/pull all the changes from my git repository.

The most important thing is that the computer will not have any SSH keys associated with gitlab therefore it will need to use username and password for authentication. I havent managed to find a way how to do this using GitPython.

I can use the following script to commit and push to the repository:

import git

full_local_path = "C:/Users/test/Desktop/WORK/Test/test_main/testfw"
branch_name = "test_branch"
repo = git.Repo(full_local_path)
origin = repo.remote(name="origin")

# COMMIT & PUSH
repo.index.commit("Some commit message123")
origin = repo.remote(name="origin")
origin.push()

print("Script complete")

The above script will work without any issues on the machine that has SSH keys for authentication.

However, my other Raspberry PI device will not have SHH keys and I want to be able to authenticate using username and password.
Currently, I manually have to fetch and pull all the changes as following:

My_raspberry@raspberrypi:~/DEV/testfw/fw $ git push
Username for 'https://xxx-gitlab.xxxxxx.lt': [email protected]
Password for 'https://[email protected]@xxx-gitlab.xxxxxx.lt': 
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 4 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 974 bytes | 487.00 KiB/s, done.
Total 8 (delta 7), reused 0 (delta 0), pack-reused 0
remote: 
remote: To create a merge request for test_branch, visit:
remote:   https://xxx-gitlab.xxxxxx.lt/test/testfw/-/merge_requests/new?merge_request%5Bsource_branch%5D=test_branch
remote: 
To https://xxx-gitlab.xxxxxx.lt/test/testfw.git
   761a21c..c10b27e  test_branch -> test_branch 

and it will work fine without any issues. I was hoping to automate this process using GitPython.

Any help is appreciated

@gitpython-developers gitpython-developers locked and limited conversation to collaborators Oct 4, 2023
@Byron Byron converted this issue into discussion #1695 Oct 4, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Development

No branches or pull requests

1 participant