Sample project

Warning Currently you can only integrate with our sandbox environment. Production integration will be possible when the APIs have reached Beta

The digital Assistance Scheme demo project can be downloaded and used by developers to view and try out the steps for authenticating as a user, accepting the relevant scopes, contacting a protected Defra API and then viewing the response from that API on screen.
The protected API endpoint that is contacted in this demo project is the EHC Metadata endpoint on the Export Health Certificates API.

Requirements

  • A version of Visual Studio supporting ASP .NET Core 3.1.
  • Login credentials for an active account on the Defra API developer portal.
  • Client ID, client secret and redirect URL for an active application created via the Defra API developer portal.

Setting up the project

  • Download or clone the GitHub repository from Defra GitHub Digital Assistance Scheme (opens in new tab).
  • Open the appsettings.Development.json file and add following from your application created in the Defra API developer portal:
    • Set the ClientId to your applications Client ID.
    • Set the ClientSecret to your applications Client secret.
    • Set the RedirectUri to your applications redirect URI - This should be a localhost address with the /auth route appended e.g. https://localhost:44396/auth.

Running the project

  • Run the project from Visual Studio and then you may follow the on screen steps which will walk through the process of:
    • Building requests.
    • Logging in using your Defra API developer portal account.
    • Accepting scopes as a user for contacting APIs.
    • Requesting access and refresh tokens.
    • Using the access token to make a request to a protected API.
    • Viewing the response from the request on screen.