Auth0 Home Blog Docs

Set language for Authentication API (React-Native Expo)

We use Universal Login with the /authorize endpoint of authentication API in a React-Native Expo app.

Using social login, there’s no documented language parameter

We call this using Expo’s AuthSession, showing a browser that does some redirects before reaching the Universal Login.

  const queryParams = ToQueryString({
    client_id: AUTH0_CLIENTID,
    redirect_uri: redirectUrl,
    response_type: 'id_token token', // id_token will return a JWT token
    scope: 'openid profile email', // retrieve the user's profile
    state: 'rnjs', // ideally, this will be a random value
    nonce: 'nonce',
    language: GetLocales(),
  });

  const authUrl = `https://${AUTH0_DOMAIN}/authorize` + queryParams;
  const response = await AuthSession.startAsync({ authUrl });

Setting language various ways seems not to affect the hosted login.

Tried setting language with management API

const body = JSON.stringify({
    enabled_locales: GetLocales(),
  });

  const authUrl = `https://${AUTH0_DOMAIN}/api/v2/tenants/settings`;
  console.log('fetch: ', authUrl);
    const response = await fetch(authUrl, {
      method: 'PATCH',
      headers: {
        authorization: 'Bearer ' + AUTH0_API_TOKEN,
        'content-type': 'application/json',
      },
      body: body,
    });