How do you provide credentials (when fetching)? #786
-
I'm trying to fetch from a private repository. My code looks something like this (with error handling replaced by let repo = gix::discover(".").unwrap();
let outcome = repo.find_default_remote(Direction::Fetch)
.unwrap()
.unwrap()
.connect(Direction::Fetch, gix::progress::Discard)
.unwrap()
.prepare_fetch(Default::default())
.unwrap()
.with_dry_run(true)
.receive(&gix::interrupt::IS_INTERRUPTED)
.unwrap() As far as I can tell, in order to provide credentials to the fetch operation, I would have to call // ...
.connect(Direction::Fetch, gix::progress::Discard)
.unwrap()
.with_credentials(|action| match action {
Action::Get(ctx) => Ok(Some(Outcome {
username: Some("username"),
password: Some("password"),
quit: false,
next: todo!(),
})),
Action::Store(_) => todo!(),
Action::Erase(_) => todo!(),
})
// ... This is as far as I've gotten however. I'm not sure why I'm expected to handle the On a possibly related note, the default configuration does not handle authentication in the same way as my |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
The reason this seems a bit cumbersome is that it's essentially the
|
Beta Was this translation helpful? Give feedback.
The reason this seems a bit cumbersome is that it's essentially the
credential-helper
protocol turned into a Rust API. The handler can obtain credentials, and later store or erase them depending on whether they worked or not. Such calls you would be ignoring then.ctx
can be turned intonext
vianext: ctx.into()
which should be fine as the username and password seem to be hardcoded anyway. Suffice to say that I consider this an example and in real life this wouldn't be hardedcoded like that.