An authenticated API for the OCF.
make dev
make test
The deployed (master) version can be accessed at
https://api.ocf.berkeley.edu/docs. Accordingly, if you are running
this locally using the command above, you can access a similarly fancy
dashboard at localhost:8000/docs
.
You can even test authenticated
endpoints by logging in on that page with OCF Keycloak SSO. Use a client_id
of
ocfstatic
and a blank client secret, and it should log you in.
Since this API is being used increasingly in the ocfstatic project, here's how to get them working together:
-
Follow the steps to setup and run
-
It's quite likely that you'll need to access mysql.ocf.berkeley.edu from your local machine to grab the data for your endpoints. This won't work immediately, so do the following:
- Go into the file
./venv/lib/python3.9/site-packages/ocflib/infra/mysql.py
and changehost
to'127.0.0.1'
- Open an ssh tunnel to Supernova (staff server) so that these requests can
actually go through on port 3306. Use the command:
ssh <username>@supernova.ocf.berkeley.edu -L 3306:mysql:3306
At this point you should be able to locally access custom endpoints that use mysql.ocf.berkeley.edu.
- Go into the file
-
To test integration with ocfstatic, you have to point requests at the API, most likely
http://127.0.0.1:8000
, or the port specified by uvicorn.