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
https://auth0.com/docs/api/authentication#social

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,
    });

Hello,

Have you found a solution?

Hi @cilere
Unless they changed the API you have to eject. We’ve used Expo with Auth0 in one solution and it’s anything but ideal. First of all: why not Firebase. Second: if you’re doing anything remotely complicated involving mobile native API:s - start with npx react-native init [--template react-native-template-typescript]

Hello Thmoas,

Thanks for your help, and I use RN cli instead of Expo now.

But what I get from another issue of auth0: Multiple languages support · Issue #119 · auth0/react-native-auth0 · GitHub

Maybe there is a way can make it works. But I don’t want to go back to try with it. So, you or another one has the same question, go and check with the issue above. Even if it’s not the same library, but I think they are using the common way to go to the login page.