request failed with status code: 401
这是我的代码:
let repo: Repository = /* get repository */;
let mut remote = repo.find_remote("origin").unwrap();
// connect returns Err, and so this panics.
remote.connect(Direction::Push).unwrap();
我也尝试传递各种凭据,但是发生相同的错误:
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|str, str_opt, cred_type| {
Ok(Cred::userpass_plaintext("natanfudge", env!("GITHUB_PASSWORD")).unwrap())
});
remote
.connect_auth(Direction::Push, Some(callbacks), None)
.unwrap();
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|str, str_opt, cred_type| {
// This line does not panic, only the connect_auth!
Ok(Cred::ssh_key_from_agent("natanfudge").expect("Could not get ssh key from ssh agent"))
});
remote
.connect_auth(Direction::Push, Some(callbacks), None)
.unwrap();
我想念什么?
我有一个本地git仓库,该仓库通过git2-rs进行维护,这是C库libgit2的一对一Rust封装器。我已经设法使用该库来暂存和提交更改。...