/orders
and /customers
. Your application would interact with these endpoints using different HTTP methods; for example, POST /orders
could create a new order or GET /orders
could retrieve the dataset of one or more orders.
For this implementation we will only define two endpoints; one for retrieving a list of all timesheets for an employee, and another which will allow an employee to create a new timesheet entry.
An HTTP GET
request to the /timesheets
endpoint will allow a user to retrieve their timesheets, and an HTTP POST
request to the /timesheets
endpoint will allow a user to add a new timesheet.
See the implementation in Node.js
Missing or invalid token
error message to the calling app.
The validations that the API should perform are:
sub
claim which identifies the principal that is the subject to the claim. In the case of the Implicit Grant flow this claim will contain the user’s identity, which will be the unique identifier for the Auth0 user. You can use this to associate any information in external systems with a particular user.
You can also use a custom claim to add another attribute of the user - such as their email address - to the Access Token and use that to uniquely identify the user.
See the implementation in Node.js
code_challenge
and the method used to generate it:
GET
request to the authorization URL should include the following values:
Parameter | Description |
---|---|
client_id | The value of your Auth0 Client Id. You can retrieve it from the Settings of your Application at the Auth0 Dashboard. |
audience | The value of your API Identifier. You can retrieve it from the Settings of your API at the Auth0 Dashboard. |
scope | The scopes which determine the claims to be returned in the ID Token and Access Token. For example, a scope of openid will return an ID Token in the response. In our example mobile app, we use the following scopes: create:timesheets read:timesheets openid profile email offline_access . These scopes allow the mobile app to call the API, obtain a , and return the user’s name , picture , and email claims in the ID Token. |
response_type | Indicates the Authentication Flow to use. For a mobile application using PKCE, this should be set to code . |
code_challenge | The generated code challenge from the code verifier. You can find instructions on generating a code challenge here. |
code_challenge_method | Method used to generate the challenge. Auth0 supports only S256 . |
redirect_uri | The URL which Auth0 will redirect the browser to after authorization has been granted by the user. The Authorization Code will be available in the code URL parameter. This URL must be specified as a valid callback URL under your Application’s Settings. |
authorization_code
from the response for an Access Token that can be used to call your API. Perform a POST
request to the Token URL including the following data:
Parameter | Description |
---|---|
grant_type | This must be set to authorization_code . |
client_id | The value of your Auth0 Client Id. You can retrieve it from the Settings of your Application at the Auth0 Dashboard. |
code_verifier | Cryptographically random key that was used to generate the code_challenge passed to authorization URL (/authorize ). |
code | The authorization_code received from the previous authorize call. |
redirect_uri | The URL must match the redirect_uri passed in the previous section to /authorize . |
audience
.offline_access
scope AND enabled Allow Offline Access for your API in the Dashboard.scope
of the user, you may want to show or hide certain UI elements. To determine the scope issued to a user, you will need to inspect the scope
which was granted when the user was authenticated. This will be a string containing all the scopes, so you therefore need to inspect this string to see whether it contains the required scope
and based on that make a decision whether to display a particular UI element.
See the implementation in Android
Authorization
header using the Bearer
scheme.
See the implementation in Android.
POST
request to the /oauth/token
endpoint using the from your authorization result.
A Refresh Token will only be present if you included the offline_access
scope in the previous authorization request and enabled Allow Offline Access for your API in the Dashboard.
Your request should include:
Parameter | Description |
---|---|
grant_type | This must be set to refresh_token . |
client_id | The value of your Auth0 Client Id. You can retrieve it from the Settings of your Application at the Auth0 Dashboard. |
refresh_token | the Refresh Token to use, from the previous authentication result. |