change_email

Function change_email 

Source
pub async fn change_email(
    client: &Client,
    api_key: &ApiKey,
    request_payload: ChangeEmailRequestBodyPayload,
    locale: Option<LanguageCode>,
) -> Result<ChangeEmailResponsePayload>
Expand description

Changes the email address associated with the user account.

See also API reference.

§Arguments

  • client - HTTP client.
  • api_key - Your Firebase project’s API key.
  • request_payload - Request body payload.
  • locale - The BCP 47 language code, eg: en-US.

§Errors

  • Error::InvalidHeaderValue - Invalid header value.
  • Error::HttpRequestError - Failed to send a request.
  • Error::ReadResponseTextFailed - Failed to read the response body as text.
  • Error::DeserializeResponseJsonFailed - Failed to deserialize the response body as JSON.
  • Error::DeserializeErrorResponseJsonFailed - Failed to deserialize the error response body as JSON.
  • Error::InvalidIdToken - Invalid ID token.
  • Error::ApiError - API error on the Firebase Auth.

§Common error codes

  • EMAIL_EXISTS: The email address is already in use by another account.
  • INVALID_ID_TOKEN:The user’s credential is no longer valid. The user must sign in again.

§Example

use fars::api;
use fars::Client;
use fars::ApiKey;

let request_payload = api::ChangeEmailRequestBodyPayload::new(
    "id-token".to_string(),
    "new-email".to_string(),
    true, // return_secure_token
);

let resopnse_payload = api::change_email(
    Client::new(),
    ApiKey::new("your-firebase-project-api-key"),
    request_payload,
    None, // locale
).await?;