From f2bc005e47fa9ae149fc5c89ec94350785c3b907 Mon Sep 17 00:00:00 2001 From: James Mead Date: Mon, 29 Jan 2018 12:54:31 +0000 Subject: [PATCH 1/3] Improve documentation about use of bearer token in API usage examples This is not the only value of bearer token which will work; any value from one of the publishing apps would work. Also it's useful to include a simple way to make the relevant environment variable in a shell. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 08e063b1..5564a51f 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,9 @@ These examples assume you're running on a machine with access to the integration * `Authorization: Bearer ` * `Accept: application/json` -Note that the value of the bearer token is stored in `/etc/govuk/manuals-publisher/env.d/ASSET_MANAGER_BEARER_TOKEN`. +Note that a suitable value for the bearer token is stored in `/etc/govuk/manuals-publisher/env.d/ASSET_MANAGER_BEARER_TOKEN`. This +environment variable can be made available in a new shell by using: +`govuk_setenv manuals-publisher bash`. #### Create an asset From 81b992d27d6cfd0632789715ca7e4b113f70a8a7 Mon Sep 17 00:00:00 2001 From: James Mead Date: Mon, 29 Jan 2018 13:03:39 +0000 Subject: [PATCH 2/3] Use existing env var in integration API usage exmaples There's no need to capture the bearer token in a new env var if we make use of `govuk_setenv`. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5564a51f..0d2aa2a2 100644 --- a/README.md +++ b/README.md @@ -254,10 +254,10 @@ deploy@integration-backend-1:$ echo `date` > tmp.txt deploy@integration-backend-1:$ cat tmp.txt Wed Sep 20 14:42:54 UTC 2017 -deploy@integration-backend-1:$ export BEARER_TOKEN=`cat /etc/govuk/manuals-publisher/env.d/ASSET_MANAGER_BEARER_TOKEN` +deploy@integration-backend-1:$ govuk_setenv manuals-publisher bash deploy@integration-backend-1:$ curl \ - -H"Authorization: Bearer $BEARER_TOKEN" \ + -H"Authorization: Bearer $ASSET_MANAGER_BEARER_TOKEN" \ -H"Accept: application/json" \ https://asset-manager.integration.publishing.service.gov.uk/assets \ --form "asset[file]=@tmp.txt" @@ -276,7 +276,7 @@ deploy@integration-backend-1:$ curl \ ``` deploy@integration-backend-1:$ curl \ - -H"Authorization: Bearer $BEARER_TOKEN" \ + -H"Authorization: Bearer $ASSET_MANAGER_BEARER_TOKEN" \ -H"Accept: application/json" \ https://asset-manager.integration.publishing.service.gov.uk/assets/59c282e2e5274a598a083a92 { From 6d654a3989dc6b16a7f2ae79e7e655b5efa34389 Mon Sep 17 00:00:00 2001 From: James Mead Date: Mon, 29 Jan 2018 13:04:31 +0000 Subject: [PATCH 3/3] Use GOVUK_APP_DOMAIN env var in integration API usage examples This corrects the examples for the new AWS integration environment and makes the examples more portable to other environments. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0d2aa2a2..72bef6d0 100644 --- a/README.md +++ b/README.md @@ -259,12 +259,12 @@ deploy@integration-backend-1:$ govuk_setenv manuals-publisher bash deploy@integration-backend-1:$ curl \ -H"Authorization: Bearer $ASSET_MANAGER_BEARER_TOKEN" \ -H"Accept: application/json" \ - https://asset-manager.integration.publishing.service.gov.uk/assets \ + https://asset-manager.$GOVUK_APP_DOMAIN/assets \ --form "asset[file]=@tmp.txt" { "_response_info":{"status":"created"}, - "id":"https://asset-manager.integration.publishing.service.gov.uk/assets/59c282e2e5274a598a083a92", + "id":"https://asset-manager.integration.govuk-internal.digital/assets/59c282e2e5274a598a083a92", "name":"tmp.txt", "content_type":"text/plain", "file_url":"https://assets-origin.integration.publishing.service.gov.uk/media/597b098a759b743e0b759a96/tmp.txt", @@ -278,10 +278,10 @@ deploy@integration-backend-1:$ curl \ deploy@integration-backend-1:$ curl \ -H"Authorization: Bearer $ASSET_MANAGER_BEARER_TOKEN" \ -H"Accept: application/json" \ - https://asset-manager.integration.publishing.service.gov.uk/assets/59c282e2e5274a598a083a92 + https://asset-manager.$GOVUK_APP_DOMAIN/assets/59c282e2e5274a598a083a92 { "_response_info":{"status":"ok"}, - "id":"https://asset-manager.integration.publishing.service.gov.uk/assets/59c282e2e5274a598a083a92", + "id":"https://asset-manager.integration.govuk-internal.digital/assets/59c282e2e5274a598a083a92", "name":"tmp.txt", "content_type":"text/plain", "file_url":"https://assets-origin.integration.publishing.service.gov.uk/media/597b098a759b743e0b759a96/tmp.txt",