user3196254
user3196254

Reputation: 125

How to set the credentials in pygit2.clone_repository?

When I clone a repo from github by pygit2, it returns: 'OSError: Failed to send request: A security error occurred'
The code is simple,

import pygit2

username = 'MyGitHubUsername'
password = 'MyGitHubPassword'
cred = pygit2.UserPass(username, password)
repo = pygit2.clone_repository('https://github.com/libgit2/libgit2', 'C:/test', bare=False, credentials=cred)

But it doesn't work, is this right?

Upvotes: 3

Views: 3717

Answers (1)

Carlos Martín Nieto
Carlos Martín Nieto

Reputation: 5277

Does using the exact same username and password work with git? If you have two-factor authentication activated, your normal password won't work. You have to create a new token and use that as your password.

Also make sure that the error is due to the credentials. "security error" could just as well mean that the HTTPS certificate of github.com is not recognised by your computer (looks like you might be using WinHTTP).

Upvotes: 3

Related Questions