XAMPPRocky / octocrab

A modern, extensible GitHub API Client for Rust.
Other
1.06k stars 258 forks source link

Cannot directly pass SecretString for token auth #594

Closed flying-sheep closed 5 months ago

flying-sheep commented 6 months ago

Given I have

let github_token: secrecy::SecretString = ...;

I can either do

octocrab::Octocrab::builder()
    .personal_token(github_token.expose_secret().to_owned())
    .build()?,

or, if I knew how to do that,

octocrab::OctocrabBuilder::new_empty()
    .with_auth(octocrab::auth::Auth::PersonalToken(github_token))
    .with_service(???)
    .with_layer(???)
    .build()?,

It seems weird to me that OctocrabBuilder<..., DefaultOctocrabBuilderConfig, NoAuth, ...>::personal_token(...) returns Self and not OctocrabBuilder<..., Auth, ...>.

XAMPPRocky commented 6 months ago

Thank you for your issue! That does seems like an oversight, I'd be happy to review a a PR that makes this possible.

flying-sheep commented 6 months ago

Done! I still wonder about the way OctocrabBuilder’s type parameters work, but that’s not relevant for this PR.