Emil
Emil

Reputation: 6893

Firebase Rest Api setting language for user or app?

Firebase has option to set language code or app language for current user in order to get verification, password reset emails in defined language like below. below is from Android SDK implementation

Additionally you can localize the verification email by updating the language code on the Auth instance before sending the email. For example:

auth.setLanguageCode("fr"); // To apply the default app language instead of explicitly setting it. // auth.useAppLanguage();

But i am using rest api within my uwp application and this option is not defined in rest api documentation

Does anybody know how to achieve this?

Upvotes: 3

Views: 1019

Answers (1)

Emil
Emil

Reputation: 6893

Anybody else is looking for solution. you need to add header as X-Firebase-Locale: 'fr'. C# code will look like as below. you can find the full implementation here

public async Task SendEmailVerificationAsync(string firebaseToken, string locale = null)
{
    var content = $"{{\"requestType\":\"VERIFY_EMAIL\",\"idToken\":\"{firebaseToken}\"}}";

    var StringContent = new StringContent(content, Encoding.UTF8, "application/json");
    if (locale != null)
        StringContent.Headers.Add("X-Firebase-Locale", locale);

    var response = await this.client.PostAsync(new Uri(string.Format(GoogleGetConfirmationCodeUrl, this.authConfig.ApiKey)), StringContent).ConfigureAwait(false);

    response.EnsureSuccessStatusCode();
}

Upvotes: 2

Related Questions