You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03-Calling-an-API/README.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This sample demonstrates how to make secure calls to an API after authenticating a user with Auth0. The calls to the API are made with the user's `access_token`. The sample makes use of Auth0's hosted login page which provides centralized authentication. The sample uses create-react-app.
4
4
5
+
There is a [short screencast](https://www.youtube.com/watch?v=ti2zMJm34Cw) available.
6
+
5
7
## Getting Started
6
8
7
9
If you haven't already done so, [sign up](https://auth0.com) for your free Auth0 account and create a new client in the [dashboard](https://manage.auth0.com). Find the **domain** and **client ID** from the settings area and add the URL for your application to the **Allowed Callback URLs** box. If you are using the server provided by the create-react-app, that URL is `http://localhost:3000`.
@@ -16,6 +18,21 @@ npm install
16
18
17
19
> **Note:** If you are not using create-react-app but are using Babel, you need to add the `stage-0` preset.
18
20
21
+
## Set up a new API
22
+
23
+
More complete documentation is available at [React Calling an API](https://auth0.com/docs/quickstart/spa/react/03-calling-an-api).
24
+
25
+
From the Auth0 dashboard, select the APIs section and select "Create API".
26
+
* Add a name for the API. `A friendly name for the API.`
27
+
* Select an identifier for the endpoint. `A logical identifier for this API. We recommend using a URL but note that this doesn’t have to be a publicly available URL, Auth0 will not call your API at all. Important! This field cannot be modified.`
28
+
29
+
For purposes of this demo, you may want to consider using http://localhost:3001 as your identifier.
30
+
31
+
You will also need to add in a new scope. `Scopes allow you to define the data that will be accessed through the applications to your API. Set a name for them and its description for better understanding.`
32
+
* Select the Scopes tab from the API section
33
+
* in the name textbox, enter in `read:messages`
34
+
* add a description for this scope ex: `permission to read messages` and click the 'add' button.
35
+
19
36
## Set the Client ID and Domain
20
37
21
38
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/`.
0 commit comments