Skip to content
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

Several user fields can be null when signing with Idp #37

Open
druskus20 opened this issue Aug 4, 2024 · 0 comments
Open

Several user fields can be null when signing with Idp #37

druskus20 opened this issue Aug 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@druskus20
Copy link

druskus20 commented Aug 4, 2024

Describe the bug
I am using part of this crate to sign in with an external identity provider (Github, in my case).

When trying to deserialize the authentication response to a firestore_db_and_auth::dto::OAuthResponse, I get the following error:

called `Result::unwrap()` on an `Err` value: RequestError(reqwest::Error { kind: Decode, source: Error("missing field `email`", line: 16, column: 1) })

The code I am running is below:

async fn sign_in_by_oauth2(
    api_key: &str,
    access_token: String,
    request_uri: String,
) -> Result<gcloud_sdk::Token, CoinError> {
    let uri = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=".to_owned()
        + api_key;

    let post_body = format!("access_token={}&providerId={}", access_token, "github.com",);
    let return_idp_credential = true;
    let return_secure_token = true;

    let json = &SignInWithIdpRequest {
        post_body,
        request_uri,
        return_idp_credential,
        return_secure_token,
    };

    dbg!(&json);
    let response: Response = reqwest::Client::new().post(&uri).json(&json).send().await?;

    //dbg!(&response.text().await?);
    let oauth_response: OAuthResponse = response.json().await?; // breaks

    //dbg!(&oauth_response);

    todo!()
}

I can instead deserialize as .text() and see that the fields email, first_name and last_name happen to be null. (While all the other fields are correct). This suggests that the aforementioned OAuthResponse's fields field should be an Option<String>

The Google Cloud docs do not mention anything:

https://cloud.google.com/identity-platform/docs/reference/rest/v1/accounts/signInWithIdp

@druskus20 druskus20 added the bug Something isn't working label Aug 4, 2024
@druskus20 druskus20 changed the title User email can be null when signing with Idp Several user fields can be null when signing with Idp Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant