FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 6fefd945 authored by Monty Dawson's avatar Monty Dawson :coffee:
Browse files

Add bash example readme, and add emphasis on warning about deploying sample apps.

parent 4d30bbc0
No related branches found
No related tags found
1 merge request!1Initial pass at example code using the Photo API.
......@@ -63,11 +63,11 @@ of how it is implemented:
* [php](./php/README.md)
* [python](./python/README.md)
All of these examples are illustrative and simply demonstrate how the Photo API can be queried
from code. They are not intended for production use and should not be deployed to environments
where they can be accessed without authentication.
**Important** All of these examples are illustrative and simply demonstrate how the Photo API can
be queried from code. They are not intended for production use and should not be deployed to
environments where they can be accessed without authentication.
### Prerequisite
### Prerequisites
All of the samples have been dockerized and contain a readme with instructions for running the
sample either via docker-compose or without docker with local dependencies.
......
# Photo API Bash sample
This directory contains an example bash script which authenticates with the API Gateway and queries
the Photo API for a photo by identifier. It makes use of `curl` to interact with the Photo API and
`jq` to parse the access token response.
## Running the example
With both [`jq`](https://stedolan.github.io/jq/) and [`curl`](https://curl.se/) installed locally,
and `../secrets.env` populated as specified in `../secrets.example.env`, the script can be run
using:
```sh
./example.sh <identifier> > example.jpeg
```
For example, the following would fetch a photo of the person with the CRSid `wgd23`:
```sh
./example.sh wgd23@v1.person.identifiers.cam.ac.uk > wgd23.jpeg
```
The example can also be run using Docker and Docker Compose, which does not require `curl` or `jq`
to be installed locally:
```sh
docker-compose run bash-example <identifier>
```
This will output the fetched photo to `./output/example.jpeg`.
## Interactions with the Photo API
The [example script](./example.sh) contains all commands used to query the Photo API and includes
comments indicating the purpose of each block. The script fetches a new access token using `curl`,
making use of the credentials defined in `../secrets.env`, and then uses this access token to
query the Photo API, again making use of `curl`. If the Photo API or access token request fail
an error will be logged and the script will exit with an unsuccessful error code.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment