Overview
This tutorial shows you how to connect to a user-restricted REST API using NHS Care Identity Service 2 (NHS CIS2) combined authentication and authorisation and the PHP programming language.
It uses Symfony to create a simple web application which authenticates the end user using our mock NHS CIS2 authorisation service, receives an access token from our authorisation server and calls the user restricted endpoint of our Hello World API.
To call a user-restricted API, the end user must be authenticated. NHS CIS2 is used to authenticate when the end user is a healthcare worker. With the combined authentication and authorisation pattern, authentication is done by NHS CIS2 but is coordinated behind our OAuth2.0 authorisation server. In exchange, you receive an access token which you need to include in the API request.
Run the code
Once you set the environment variables, you are ready to run the project.
Run the application
You should first source your environment variable file before executing your application.
source .env
symfony server:start
Run using Makefile
Alternatively, you can set your environment variables in a file named .env. Then use the make command: make run.
Last edited: 12 September 2022 6:13 pm