|
| 1 | +# How to run Scripts |
| 2 | + |
| 3 | +## First Steps |
| 4 | + |
| 5 | +### Install packages |
| 6 | + |
| 7 | +The tooling we use to manage our packages in poetry so this needs to be installed on your local machine in order to run the scripts. |
| 8 | + |
| 9 | +Then run the following command in the scripts directory |
| 10 | + |
| 11 | +``` |
| 12 | +poetry install |
| 13 | +``` |
| 14 | + |
| 15 | +## Script Specific |
| 16 | + |
| 17 | +### Get CIS2 Access Token for Int Environment |
| 18 | + |
| 19 | +#### Set Environment Variables |
| 20 | + |
| 21 | +You will require the following environment variables in order to run the script: |
| 22 | + |
| 23 | +``` |
| 24 | +export APIGEE_ENVIRONMENT=int |
| 25 | +export APPLICATION_CLIENT_ID={application_client_id} |
| 26 | +export APPLICATION_CLIENT_SECRET={application_client_secret} |
| 27 | +``` |
| 28 | + |
| 29 | +#### Select an identifier |
| 30 | + |
| 31 | +There are a different levels of authenticator assurance levels eg. AAL3. |
| 32 | +For VRS CIS2 users are only accessible to access selected APIs. |
| 33 | +Please find a list of test users detailed in this page: |
| 34 | +https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/testing-apis-with-our-mock-authorisation-service#test-users-for-cis2-authentication |
| 35 | +This can be used to select your identifier for the next step. |
| 36 | +i.e. 656005750108 to test with a CIS2 user with AAL3 authenticator assurance level. |
| 37 | + |
| 38 | +#### Run the script |
| 39 | + |
| 40 | +Then run the following command in the scripts directory |
| 41 | + |
| 42 | +``` |
| 43 | +poetry run python3 get_cis2_access_token_int.py |
| 44 | +``` |
| 45 | + |
| 46 | +You will be prompted to "Enter an identifier: " |
| 47 | + |
| 48 | +Enter the identifier selected in previous step eg. 656005750108 |
| 49 | + |
| 50 | +In your terminal you should see a response that includes an access token |
| 51 | + |
| 52 | +e.g. |
| 53 | + |
| 54 | +``` |
| 55 | +{'access_token': 'EFFs3EeT0SZbF2J14LvM93vVDTaA', 'expires_in': '599', 'refresh_token': 'BDEcXjJI36DJA8Dlw8wS0jCuYJJqC8tK', 'refresh_token_expires_in': '43199', 'refresh_count': '0', 'token_type': 'Bearer'} |
| 56 | +``` |
| 57 | + |
| 58 | +### Get NHS Login Access Token for Int Environment |
| 59 | + |
| 60 | +#### Set Environment Variables |
| 61 | + |
| 62 | +You will require the following environment variables in order to run the script: |
| 63 | + |
| 64 | +``` |
| 65 | +export APIGEE_ENVIRONMENT=int |
| 66 | +export APPLICATION_CLIENT_ID={application_client_id} |
| 67 | +export APPLICATION_CLIENT_SECRET={application_client_secret} |
| 68 | +``` |
| 69 | + |
| 70 | +#### Select an identifier |
| 71 | + |
| 72 | +There are a different identity proofing levels eg. p9. |
| 73 | +For VRS p9 users are only accessible to access selected APIs. |
| 74 | +Please find a list of test users detailed in this page: |
| 75 | +https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/testing-apis-with-our-mock-authorisation-service#test-users-for-nhs-login |
| 76 | +This can be used to select your identifier for the next step. |
| 77 | +i.e. 9912003071 to test with a p9 user. |
| 78 | + |
| 79 | +#### Run the script |
| 80 | + |
| 81 | +Then run the following command in the scripts directory |
| 82 | + |
| 83 | +``` |
| 84 | +poetry run python3 get_nhs_login_access_token_int.py |
| 85 | +``` |
| 86 | + |
| 87 | +You will be prompted to "Enter an identifier: " |
| 88 | + |
| 89 | +Enter the identifier selected in previous step eg. 9912003071 |
| 90 | + |
| 91 | +In your terminal you should see a response that includes an access token |
| 92 | + |
| 93 | +e.g. |
| 94 | + |
| 95 | +``` |
| 96 | +{'access_token': 'EFFs3EeT0SZbF2J14LvM93vVDTaA', 'expires_in': '599', 'refresh_token': 'BDEcXjJI36DJA8Dlw8wS0jCuYJJqC8tK', 'refresh_token_expires_in': '43199', 'refresh_count': '0', 'token_type': 'Bearer'} |
| 97 | +``` |
| 98 | + |
| 99 | +### Get App Restricted Access Token for Int Environment |
| 100 | + |
| 101 | +Application restricted authentication is when a system is trying to access an API rather than a person. For example the Validated Relationship Service (VRS) will need an app restricted access token in order to call the Personal Demographic Service (PDS) API. |
| 102 | +https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation#application-restricted-apis |
| 103 | + |
| 104 | +#### Set Environment Variables |
| 105 | + |
| 106 | +You will require the following environment variables in order to run the script: |
| 107 | + |
| 108 | +``` |
| 109 | +export APIGEE_ENVIRONMENT=int |
| 110 | +export APPLICATION_CLIENT_ID={vrs_application_client_id} |
| 111 | +export APPLICATION_CLIENT_KID={vrs_application_client_secret} |
| 112 | +export APPLICATION_CLIENT_PRIVATE_KEY={vrs_application_client_private_key} |
| 113 | +``` |
| 114 | + |
| 115 | +Note with VRS_CLIENT_PRIVATE_KEY it needs to be wrapped in double quotation marks otherwise there can be formatting errors |
| 116 | + |
| 117 | +#### Run the script |
| 118 | + |
| 119 | +Then run the following command in the scripts directory |
| 120 | + |
| 121 | +``` |
| 122 | +poetry run python3 get_app_access_token_int.py |
| 123 | +``` |
| 124 | + |
| 125 | +In your terminal you should see a response that includes an access token |
| 126 | + |
| 127 | +e.g. |
| 128 | + |
| 129 | +``` |
| 130 | +{'access_token': 'EFFs3EeT0SZbF2J14LvM93vVDTaA', 'expires_in': '599', 'refresh_token': 'BDEcXjJI36DJA8Dlw8wS0jCuYJJqC8tK', 'refresh_token_expires_in': '43199', 'refresh_count': '0', 'token_type': 'Bearer'} |
| 131 | +``` |
| 132 | + |
| 133 | +### Trouble Shooting |
| 134 | + |
| 135 | +If you have issues with the script, a good place to start is to ensure the environment variables are accessible to poetry. This can be achieved by installing the poetry dotenv plugin |
| 136 | + |
| 137 | +Run this command |
| 138 | + |
| 139 | +``` |
| 140 | +poetry plugin add poetry-dotenv-plugin |
| 141 | +``` |
0 commit comments