|
| 1 | +# Auth0 React Token Renewal |
| 2 | + |
| 3 | +This sample demonstrates how to silently renew `access_token`s in a React application with Auth0. The sample uses the create-react-app. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +Create a new API in the [APIs section](https://manage.auth0.com/#/apis) and provide an identifier for it. |
| 8 | + |
| 9 | +Clone the repo or download it from the React quickstart page in Auth0's documentation. Install create-react-app and the dependencies for the app. |
| 10 | + |
| 11 | +```bash |
| 12 | +npm install -g create-react-app |
| 13 | +cd 05-Token-Renewal |
| 14 | +npm install |
| 15 | +``` |
| 16 | + |
| 17 | +## Set the Client ID, Domain, and API URL |
| 18 | + |
| 19 | +If you download the sample from the quickstart page, it will come pre-populated with the **client ID** and **domain** for your application. If you clone the repo directly from Github, rename the `auth0-variables.js.example` file to `auth0-variables.js` and provide the **client ID** and **domain** there. This file is located in `src/Auth/`. |
| 20 | + |
| 21 | +You should also provide the identifier for the API you create in the Auth0 dashboard as your `apiUrl`. |
| 22 | + |
| 23 | +## Set Up the `silent.html` File |
| 24 | + |
| 25 | +If you download the sample from the quickstart page, it will come pre-populated with the **client ID** and **domain** for your application. If you clone the repo directly from Github, edit `silent.html` and add your **client ID** and **domain**. |
| 26 | + |
| 27 | +## Run the Application |
| 28 | + |
| 29 | +The development server that comes with create-react-app can be used to serve the application. |
| 30 | + |
| 31 | +```bash |
| 32 | +npm start |
| 33 | +``` |
| 34 | + |
| 35 | +The application will be served at `http://localhost:3000`. |
| 36 | + |
| 37 | +## Making It Live |
| 38 | + |
| 39 | +To make the silent authentication work on a live environment, you'll need to edit the two `localhost` urls in `silent.html` and the one `localhost` url you have in the `auth0-variables.ts` file. |
| 40 | + |
| 41 | +## Troubleshooting |
| 42 | +If you see an error on renewal saying `login_required`, that means you may be using the Auth0 dev keys for whichever social login you're testing. You'll need to add your own keys for this to work. |
| 43 | + |
| 44 | +## What is Auth0? |
| 45 | + |
| 46 | +Auth0 helps you to: |
| 47 | + |
| 48 | +* Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**. |
| 49 | +* Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**. |
| 50 | +* Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user. |
| 51 | +* Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely. |
| 52 | +* Analytics of how, when and where users are logging in. |
| 53 | +* Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules). |
| 54 | + |
| 55 | +## Create a free Auth0 account |
| 56 | + |
| 57 | +1. Go to [Auth0](https://auth0.com/signup) and click Sign Up. |
| 58 | +2. Use Google, GitHub or Microsoft Account to login. |
| 59 | + |
| 60 | +## Issue Reporting |
| 61 | + |
| 62 | +If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. |
| 63 | + |
| 64 | +## Author |
| 65 | + |
| 66 | +[Auth0](auth0.com) |
| 67 | + |
| 68 | +## License |
| 69 | + |
| 70 | +This project is licensed under the MIT license. See the [LICENSE](LICENSE.txt) file for more info. |
| 71 | + |
0 commit comments