Skip to content

Commit c2ee9b2

Browse files
docs: update examples to include Accept-Language header configuration
1 parent 00bc883 commit c2ee9b2

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

EXAMPLES.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Examples using react-native-auth0
22

3+
- [SDK Configuration](#sdk-configuration)
4+
- [Setting the Accept-Language Header](#setting-the-accept-language-header)
35
- [Authentication API](#authentication-api)
46
- [Login with Password Realm Grant](#login-with-password-realm-grant)
57
- [Get user information using user's access_token](#get-user-information-using-users-access_token)
@@ -21,6 +23,59 @@
2123
- [iOS](#ios)
2224
- [Expo](#expo)
2325

26+
## SDK Configuration
27+
28+
This section covers examples related to configuring the behavior of the Auth0 SDK itself.
29+
30+
### Setting the Accept-Language Header
31+
32+
You can configure the SDK to automatically send the `Accept-Language` HTTP header with all outgoing requests. This is useful if you want to signal your preferred language(s) to Auth0, which might influence the language used in error messages or other localized content returned by Auth0 APIs.
33+
34+
35+
Provide the `acceptLanguage` option during initialization. The value should be a string conforming to the standard `Accept-Language` header format (e.g., `en-US`, `fr-CA,fr;q=0.9`).
36+
37+
**Using the `Auth0` class:**
38+
39+
```js
40+
import Auth0 from 'react-native-auth0';
41+
42+
const auth0 = new Auth0({
43+
domain: 'YOUR_AUTH0_DOMAIN',
44+
clientId: 'YOUR_AUTH0_CLIENT_ID',
45+
// Set preferred language(s)
46+
acceptLanguage: 'es-ES,es;q=0.9'
47+
});
48+
49+
// All subsequent API calls made using this auth0 instance
50+
// (e.g., auth0.auth.passwordlessWithSMS())
51+
// will include the 'Accept-Language: es-ES,es;q=0.9' header.
52+
```
53+
54+
**Using the Auth0Provider hook:**
55+
56+
```js
57+
import { Auth0Provider } from 'react-native-auth0';
58+
59+
const App = () => {
60+
return (
61+
<Auth0Provider
62+
domain="YOUR_AUTH0_DOMAIN"
63+
clientId="YOUR_AUTH0_CLIENT_ID"
64+
// Set preferred language(s)
65+
acceptLanguage="de-DE"
66+
>
67+
{/* YOUR APP */}
68+
</Auth0Provider>
69+
);
70+
};
71+
72+
export default App;
73+
74+
// All subsequent API calls made via the useAuth0() hook derived
75+
// from this provider will include the 'Accept-Language: de-DE' header.
76+
77+
```
78+
2479
## Authentication API
2580

2681
Unlike web authentication, we do not provide a hook for integrating with the Authentication API.

0 commit comments

Comments
 (0)