Skip to content

Commit 4694fdb

Browse files
committed
Merge branch 'master' of github.com:auth0-samples/auth0-react-samples
2 parents 92d318d + 7b8e4dd commit 4694fdb

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

03-Calling-an-API/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
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.
44

5+
There is a [short screencast](https://www.youtube.com/watch?v=ti2zMJm34Cw) available.
6+
57
## Getting Started
68

79
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
1618

1719
> **Note:** If you are not using create-react-app but are using Babel, you need to add the `stage-0` preset.
1820
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+
1936
## Set the Client ID and Domain
2037

2138
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

Comments
 (0)