-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support for signInWithPassword
#76
Comments
Hey, First of all, PRs always welcome :) So, I'll review it. I mostly curious though why would you prefer this over service accounts? Can you describe a bit your case to understand what benefits this give you? (Again, even if they are rare I don't have anything against adding this, I just want to clarify it for myself - the needs). |
My use case is that I'm using this app https://brewfather.app/ as part of my beer homebrewing process and while they have a public API it's very limited compared to what the app is actually capable of. I'll submit a PR, thank you 🥳 |
So, you can use the Firestore gRPC API using this approach on their cloud project? Have you tested it already? I find this really interesting. |
It indeed works! Here's an example of it: #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DefaultFermentables {
#[serde(rename = "array_data")]
pub array_data: Vec<DefaultFermentable>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DefaultFermentable {
pub origin: Option<String>,
pub supplier: Option<String>,
pub attenuation: Option<f64>,
pub ibu_per_amount: Option<f64>,
pub not_fermentable: Option<bool>,
pub potential_percentage: Option<f64>,
#[serde(rename = "type")]
pub type_field: String,
pub color: f64,
pub potential: Option<f64>,
pub name: String,
#[serde(rename = "_id")]
pub id: String,
pub acid: Option<f64>,
pub moisture: Option<f64>,
pub coarse_fine_diff: Option<f64>,
pub max_in_batch: Option<f64>,
pub hidden: Option<bool>,
pub protein: Option<f64>,
pub notes: Option<String>,
pub diastatic_power: Option<f64>,
pub grain_category: Option<String>,
pub lovibond: Option<f64>,
pub p_h: Option<f64>,
pub fgdb: Option<f64>,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let db = firestore::FirestoreDb::with_options_token_source(
FirestoreDbOptions::new("brewfather-app".into()),
vec![],
gcloud_sdk::TokenSourceType::UserAccount(gcloud_sdk::UserAccount {
api_key: "nope".into(),
email: "nope".into(),
password: "nope".into(),
}),
)
.await?;
let foo = db
.fluent()
.select()
.by_id_in("resources/default_ingredients/default_fermentables")
.obj::<DefaultFermentables>()
.one("default_0001")
.await?;
println!("{:#?}", &foo.unwrap().array_data[..2]);
Ok(())
} prints:
|
Well, that's setup I've never heard before, but if it works, then fine with me. Let's review it 👍🏻 |
Greetings!
A while back I asked about
signInWithPassword
in firestore-rs where I was clearly confused 😉Since then I've figured stuff out and actually managed to implement support for email/password auth in
gcloud-sdk-rs
however I don't think the implementation is very good or particularly in line with what you'd wish for.I've basically added the following in
credentials.rs
:As well as some minor glue to
TokenSource
andGoogleEnvironment
.With the above modifications it's possible to use it in
firestore-rs
like this:I'd be happy to submit it as a PR for it if you'd like to have a closer look at it. However, before doing that, I thought I'd create an issue and discuss if you have a better idea of how to implement it 😃
The text was updated successfully, but these errors were encountered: