-
First generate an API key using Notify's admin interface. The API key consists of three parts:
|--name---| |-----------service uuid-----------| |-----------secret uuid------------| yourkeyname-aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa-bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
-
Any generated tokens expire after 30 seconds so we need to generate them per request. The easiest way to do this is to write a small script (e.g.,
key
). We need our service and secret uuids from the API key and be sure to trim the newline from the end.jwt encode \ --iss "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" \ --secret="bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb" \ --alg=HS256 | tr -d "\n"
-
Now we should be able to make it executable
chmod +x key
and test calling it./key
Now the hard part is done we just need to build requests that use our script:
xh get https://api.notifications.service.gov.uk/v2/templates Authorization:"Bearer $(./key)"