Skip to content

Commit

Permalink
change example to not imply hard coded password is necesary
Browse files Browse the repository at this point in the history
  • Loading branch information
joswig committed Jan 21, 2025
1 parent 9c95fd0 commit 8329b0b
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions docs/api/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ Set it to the following:

```json
{
"headers" :
{
"headers": {
"x-hasura-admin-secret": "<YOUR_ADMIN_SECRET>",
"x-hasura-user-id": "<YOUR_AERIE_USERNAME>",
"x-hasura-role": "viewer"
Expand All @@ -168,11 +167,11 @@ If you do not know the admin secret for your venue, you can instead run a pre-re
<summary><b>For Aerie versions before v2.2.0</b></summary>

1. Access the Global Environment by clicking on "No Environment" -> "Environments..." in the top-right of the page.
Set it to the following:
Set it to the following:

```json
{
"headers" :
{
"headers": {
"Authorization": "Bearer {{user}}",
"x-hasura-role": "viewer"
}
Expand All @@ -181,20 +180,21 @@ Set it to the following:

2. In the Query Window, click on Pre-request. Select Enable Pre-request script.


3. Enter the following pre-request script:

```js
// Fetch a new token from the Gateway
const res = await altair.helpers.request(
'POST',
'/auth/login', // AUTH ENDPOINT OF THE DEPLOYMENT
{
body: { "username": "<YOUR_AERIE_USERNAME>", "password": "<YOUR_AERIE_PASSWORD>"}, // CREDENTIALS TO LOG IN AS
headers: {"Content-Type": "application/json"}
});
if(res.success) {
body: { username: '<YOUR_AERIE_USERNAME>', password: '<YOUR_AERIE_PASSWORD>' }, // CREDENTIALS TO LOG IN AS
headers: { 'Content-Type': 'application/json' },
},
);
if (res.success) {
const token = res.token;
await altair.helpers.setEnvironment("user", token);
await altair.helpers.setEnvironment('user', token);
} else {
altair.log(res);
}
Expand Down Expand Up @@ -222,9 +222,10 @@ const res = await altair.helpers.request(
'POST',
'/auth/login', // AUTH ENDPOINT OF THE DEPLOYMENT
{
body: { "username": "<YOUR_AERIE_USERNAME>", "password": "<YOUR_AERIE_PASSWORD>"}, // CREDENTIALS TO LOG IN AS
headers: {"Content-Type": "application/json"}
});
body: { username: '<YOUR_AERIE_USERNAME>', password: '<YOUR_AERIE_PASSWORD>' }, // CREDENTIALS TO LOG IN AS
headers: { 'Content-Type': 'application/json' },
},
);
```

Replace `<YOUR_AERIE_USERNAME>` and `<YOUR_AERIE_PASSWORD>` with the username and password you use to sign in to Aerie.
Expand All @@ -234,6 +235,7 @@ By default, you will make queries using the `viewer` role. If you want to use a
select `Set Headers` from the top of the left-side sidebar and update the header `x-hasura-role` to a different role you are permitted to use.

To see the list of your permitted roles, use the following query:

```gql
{
users_and_roles {
Expand All @@ -253,11 +255,14 @@ You can query the API in Python using the [requests](https://pypi.org/project/re

```python
import json
import os
import requests

token = os.getenv('AERIE_TOKEN')

response = requests.post(
url='http://localhost:8080/v1/graphql', # Change from 'localhost' as needed.
headers={ 'Authorization': 'Bearer YOUR_TOKEN_HERE' }, # See 'Authorization' section above to get this.
headers={ 'Authorization': f'Bearer {token}' }, # See 'Authorization' section above to get this.
json={ 'query': 'query { plan { id } }' }
)

Expand Down

0 comments on commit 8329b0b

Please sign in to comment.