Skip to content

Commit

Permalink
Update all curl documentation examples and references with new x-medu…
Browse files Browse the repository at this point in the history
…sa-access-token header (#6326)

## What

This is to update incorrect documentation in regards to authentication to the Admin API - raised in #6264.

## Why

Because the current documentation has been incorrect since the September 2023 release of [v1.17.0](https://github.com/medusajs/medusa/releases/tag/v1.17.0), which had breaking changes to API token usage.

## How

Simple search and replace. I was asked to replace occurrences under `www/apps/docs/content/` but there were also additional places where I thought references should also be updated:

- `packages/medusa/src/api/`
- `www/apps/api-reference/`

Feel free to revert them as needed.

There is also some inconsistency between the format shown in examples e.g. `<API_TOKEN>` vs `{api_token}` vs `{access_token}`.

I have kept the format the same in all cases as the original, as surrounding documentation text would not have format updated as well. I suggest maybe reviewing the documentation and keeping to a consistent format e.g. `<API_TOKEN>`.

 
## Testing 

I have not tested these changes. I would assume the `packages/medusa/src/api/` changes may need more thorough testing?
  • Loading branch information
irab authored Feb 7, 2024
1 parent e2cb72e commit 44470bf
Show file tree
Hide file tree
Showing 32 changed files with 217 additions and 217 deletions.
38 changes: 19 additions & 19 deletions www/apps/api-reference/app/_mdx/admin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ by passing to the `expand` query parameter the value `collection`:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?expand=collection" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -416,7 +416,7 @@ pass to the `expand` query parameter the value `variants,collection`:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?expand=variants,collection" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -478,7 +478,7 @@ For example:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?expand" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -572,7 +572,7 @@ parameter:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?fields=title" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -632,7 +632,7 @@ value to the `expand` query parameter. For example:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?fields=title&expand" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -696,7 +696,7 @@ For example, to select the `title` and `handle` of products:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?fields=title,handle" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -755,7 +755,7 @@ entity. For example:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?fields" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -811,7 +811,7 @@ relations aren't retrieved as well. For example:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?fields&expand" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -891,7 +891,7 @@ For example:

```bash
curl "http://localhost:9000/admin/products?title=Shirt" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -905,7 +905,7 @@ For example, if the string has spaces, you can encode the space with `+` or

```bash
curl "http://localhost:9000/admin/products?title=Blue%20Shirt" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -924,7 +924,7 @@ For example:

```bash
curl "http://localhost:9000/admin/products?offset=1" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -939,7 +939,7 @@ For example:

```bash
curl "http://localhost:9000/admin/products?is_giftcard=true" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -955,7 +955,7 @@ For example:

```bash
curl -g "http://localhost:9000/admin/products?created_at[lt]=2023-02-17" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -968,7 +968,7 @@ For example:

```bash
curl -g "http://localhost:9000/admin/products?created_at[lt]=2023-02-17T07:22:30Z" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -985,7 +985,7 @@ For example:

```bash
curl -g "http://localhost:9000/admin/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7&sales_channel_id[]=sc_234PGVB42PZ7N3YQEP2WDM7PC7" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```


Expand All @@ -1006,7 +1006,7 @@ For example:

```bash
curl -g "http://localhost:9000/admin/products?created_at[lt]=2023-02-17&created_at[gt]=2022-09-17" \
-H 'Authorization: Bearer {api_token}'
-H 'x-medusa-access-token: {api_token}'
```

<Feedback
Expand Down Expand Up @@ -1046,7 +1046,7 @@ For example, to limit the number of products returned in the List Products API R
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?limit=5" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -1123,7 +1123,7 @@ sort products by their `created_at` attribute by setting `order` to
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?order=created_at" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down Expand Up @@ -1179,7 +1179,7 @@ descending, pass a dash (`-`) before the attribute name. For example:
value: 'curl',
code: {
source: `curl "http://localhost:9000/admin/products?order=-created_at" \
-H 'Authorization: Bearer {api_token}'`,
-H 'x-medusa-access-token: {api_token}'`,
lang: `bash`,
}
},
Expand Down
2 changes: 1 addition & 1 deletion www/apps/docs/content/contribution/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ import TabItem from '@theme/TabItem';

```bash
curl -L -X POST '<BACKEND_URL>/admin/uploads' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: text/csv' \
-F 'files=@"<FILE_PATH_1>"'
```
Expand Down
6 changes: 3 additions & 3 deletions www/apps/docs/content/development/batch-jobs/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ For example, this creates a batch job of the type `publish-products`:

```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"type": "publish-products",
Expand Down Expand Up @@ -433,7 +433,7 @@ You can retrieve the batch job afterward to get its status and view details abou

```bash
curl -L -X GET '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
# <BATCH_JOB_ID> is the ID of the batch job
```

Expand Down Expand Up @@ -517,7 +517,7 @@ To process the batch job, send a request to [confirm the batch job](https://docs

```bash
curl -L -X POST '<BACKEND_URL>/admin/batch-jobs/<BATCH_JOB_ID>/confirm' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
# <BATCH_JOB_ID> is the ID of the batch job
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ You can retrieve a list of publishable API keys by sending a request to the [Lis

```bash
curl -L -X GET '<BACKEND_URL>/admin/publishable-api-keys' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -217,7 +217,7 @@ You can create a publishable API key by sending a request to the [Create Publish

```bash
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"title": "Web API Key"
Expand Down Expand Up @@ -310,7 +310,7 @@ You can update a publishable API key’s details by sending a request to the [Up

```bash
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"title": "Web API Key"
Expand Down Expand Up @@ -398,7 +398,7 @@ You can revoke a publishable API key by sending a request to the [Revoke Publish

```bash
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/revoke' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -475,7 +475,7 @@ You can delete a publishable API key by sending a request to the [Delete Publish

```bash
curl -L -X DELETE '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -573,7 +573,7 @@ You can retrieve the list of sales channels associated with a publishable API ke

```bash
curl -L -X GET '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -681,7 +681,7 @@ You can add a sales channel to a publishable API key by sending a request to the

```bash
curl -L -X POST '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"sales_channel_ids": [
Expand Down Expand Up @@ -801,7 +801,7 @@ You can delete a sales channel from a publishable API key by sending a request t

```bash
curl -L -X DELETE '<BACKEND_URL>/admin/publishable-api-keys/<PUBLISHABLE_API_KEY>/sales-channels/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"sales_channel_ids": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ You can create a customer group by sending a request to the Create Customer Grou

```bash
curl -L -X POST '<BACKEND_URL>/admin/customer-groups' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "VIP"
Expand Down Expand Up @@ -191,7 +191,7 @@ You can get a list of all customer groups by sending a request to the List Custo

```bash
curl -L -X GET '<BACKEND_URL>/admin/customer-groups' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -260,7 +260,7 @@ You can retrieve a single customer group by sending a request to the Get a Custo

```bash
curl -L -X GET '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -346,7 +346,7 @@ You can update a customer group’s data by sending a request to the Update Cust

```bash
curl -L -X POST '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"metadata": {
Expand Down Expand Up @@ -424,7 +424,7 @@ You can delete a customer group by sending a request to the Delete a Customer Gr

```bash
curl -L -X DELETE '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -520,7 +520,7 @@ You can add a customer to a group by sending a request to the Customer Group’s

```bash
curl -L -X POST '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"customer_ids": [
Expand Down Expand Up @@ -608,7 +608,7 @@ You can retrieve a list of all customers in a customer group using the List Cust

```bash
curl -L -X GET '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -714,7 +714,7 @@ You can remove customers from a customer group by sending a request to the Remov

```bash
curl -L -X DELETE '<BACKEND_URL>/admin/customer-groups/<CUSTOMER_GROUP_ID>/customers/batch' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"customer_ids": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ You can show a list of customers by sending a request to the [List Customers API

```bash
curl -L -X GET '<BACKEND_URL>/admin/customers' \
-H 'Authorization: Bearer <API_TOKEN>'
-H 'x-medusa-access-token: <API_TOKEN>'
```

</TabItem>
Expand Down Expand Up @@ -214,7 +214,7 @@ You can create a customer account by sending a request to the [Create a Customer

```bash
curl -L -X POST '<BACKEND_URL>/admin/customers' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "<EMAIL>",
Expand Down Expand Up @@ -314,7 +314,7 @@ You can edit a customer’s information by sending a request to the [Update a Cu

```bash
curl -L -X POST '<BACKEND_URL>/admin/customers/<CUSTOMER_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'x-medusa-access-token: <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"first_name": "<FIRST_NAME>"
Expand Down
Loading

0 comments on commit 44470bf

Please sign in to comment.