api-example-java-client is a Spring based java application that provides a reference implementation of a HMRC client application.
It accesses three endpoints, each with their own authorisation requirements:
- Hello World - an Open endpoint that responds with the message “Hello World!”
- Hello Application - an Application-restricted endpoint (accessed using OAuth 2.0 client-credentials flow) that responds with the message “Hello Application!”
- Hello User - a User-restricted endpoint (accessed using OAuth 2.0 authorization-code flow) that responds with the message “Hello User!”
The implementation of the Hello User flow requests an OAuth 2.0 access token and subsequently uses that token to access the secured endpoint.
Application developers need to register with the HMRC Developer Hub.
Once this is done they will need to create an application and subscribe to the Hello World test applicaion.
The client id and client secret for this application can be obtained from the applications Client ID
and Client secrets
menu items.
The client-id
and client-secret
for the application will need to be added to src/main/resources/application.yml
You will need to add the Redirect URI
http://localhost:8080 to your HMRC Developer Hub application.
API documentation is available on the HMRC Developer Hub
The server can be started with the following command:
./gradlew bootRun
Once running, the application provides the following endpoints:
http://localhost:8080/hello-world
http://localhost:8080/hello-application
http://localhost:8080/hello-user
- Make sure that you are using java 8 ensure that gradle is configured for your java 8 installation.
This code is open source software licensed under the Apache 2.0 License.