docs: added publishable API keys documentation pages (#2972)

* docs: added publishable api keys docs

* Update docs/content/advanced/admin/manage-publishable-api-keys.mdx

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>

* Update publishable-api-keys.mdx

* Update docs/content/advanced/storefront/use-sales-channels.mdx

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* added note in admin how-to guide

* added note in conceptual guide

* Update docs/content/advanced/backend/publishable-api-keys/index.md

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* small fixes

Co-authored-by: Frane Polić <16856471+fPolic@users.noreply.github.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Shahed Nasser
2023-01-11 17:36:51 +02:00
committed by GitHub
parent c94ce03aa2
commit 4156e280ab
16 changed files with 826 additions and 39 deletions

View File

@@ -26,7 +26,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKeys.addSalesChannels(publishableApiKeyId, {
* medusa.admin.publishableApiKeys.addSalesChannelsBatch(publishableApiKeyId, {
* sales_channel_ids: [
* {
* id: channel_id
@@ -39,7 +39,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-keys/afasf/batch' \
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-keys/{pak_id}/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{

View File

@@ -22,16 +22,21 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKey.create()
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* medusa.admin.publishableApiKeys.create({
* title
* })
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-keys' \
* --header 'Authorization: Bearer {api_token}'
* -d '{ "created_by": "user_123" }'
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "title": "Web API Key"
* }'
* security:
* - api_token: []
* - cookie_auth: []

View File

@@ -26,7 +26,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKeys.removeSalesChannels(publishableApiKeyId, {
* medusa.admin.publishableApiKeys.deleteSalesChannelsBatch(publishableApiKeyId, {
* sales_channel_ids: [
* {
* id: channel_id
@@ -39,7 +39,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/publishable-api-keys/afasf/batch' \
* curl --location --request DELETE 'https://medusa-url.com/admin/publishable-api-keys/{pka_id}/batch' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{

View File

@@ -17,14 +17,14 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKey.delete(key_id)
* .then(({ id, object, deleted }) => {
* console.log(id)
* })
* medusa.admin.publishableApiKeys.delete(publishableApiKeyId)
* .then(({ id, object, deleted }) => {
* console.log(id)
* })
* - lang: Shell
* label: cURL
* source: |
* curl --location --request DELETE 'https://medusa-url.com/admin/publishable-api-key/{id}' \
* curl --location --request DELETE 'https://medusa-url.com/admin/publishable-api-key/{pka_id}' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []

View File

@@ -17,16 +17,15 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKey.retrieve(pubKeyId)
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* medusa.admin.publishableApiKeys.retrieve(publishableApiKeyId)
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/publishable-api-keys/pubkey_123' \
* curl --location --request GET 'https://medusa-url.com/admin/publishable-api-keys/{pka_id}' \
* --header 'Authorization: Bearer {api_token}'
* -d '{ "created_by": "user_123" }'
* security:
* - api_token: []
* - cookie_auth: []

View File

@@ -21,13 +21,13 @@ import { extendedFindParamsMixin } from "../../../../types/common"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKeys.listSalesChannels()
* .then(({ sales_channels, limit, offset, count }) => {
* console.log(sales_channels)
* .then(({ sales_channels }) => {
* console.log(sales_channels.length)
* })
* - lang: Shell
* label: cURL
* source: |
* curl --location --request GET 'https://medusa-url.com/admin/publishable-api-keys/pk_123/sales-channels' \
* curl --location --request GET 'https://medusa-url.com/admin/publishable-api-keys/{pka_id}/sales-channels' \
* --header 'Authorization: Bearer {api_token}'
* security:
* - api_token: []

View File

@@ -24,7 +24,7 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKeys.list()
* .then(({ publishable_api_keys }) => {
* .then(({ publishable_api_keys, count, limit, offset }) => {
* console.log(publishable_api_keys)
* })
* - lang: Shell

View File

@@ -18,16 +18,15 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKey.revoke()
* medusa.admin.publishableApiKeys.revoke(publishableApiKeyId)
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-keys/pubkey_123/revoke' \
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-keys/{pka_id}/revoke' \
* --header 'Authorization: Bearer {api_token}'
* -d '{ "created_by": "user_123", "revoked_by": "user_123" }'
* security:
* - api_token: []
* - cookie_auth: []

View File

@@ -24,20 +24,20 @@ import PublishableApiKeyService from "../../../../services/publishable-api-key"
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.publishableApiKey.update(publishable_key_id, {
* medusa.admin.publishableApiKeys.update(publishableApiKeyId, {
* title: "new title"
* })
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* .then(({ publishable_api_key }) => {
* console.log(publishable_api_key.id)
* })
* - lang: Shell
* label: cURL
* source: |
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-key/{id}' \
* curl --location --request POST 'https://medusa-url.com/admin/publishable-api-key/{pka_id}' \
* --header 'Authorization: Bearer {api_token}' \
* --header 'Content-Type: application/json' \
* --data-raw '{
* "title": "updated title"
* "title": "new title"
* }'
* security:
* - api_token: []