View on GitHub

easitrace

« Back to DAERA

Movement Services | DAERA (APHIS) - Authentication

DAERA is the Movement Service for Cattle in Northern Ireland.

Overview

This document covers several aspects of the authentication for DAERA’s APHIS service.

Sections

Flow
Pre-Requisites Getting Started

Flow

The authentication for this service has recently changed. Previously you would have supplied login credentials to EasiTrace which would have held them on your behalf and used them for calls to DAERA, however as of July 2020 this is no longer the case and the burden of the authentication now falls on the caller of EasiTrace.

Authentication Flow

Prerequisites

Note, that in order for you to use DAERA (APHIS) you will need to request that you are setup as a Third-Party provider with DAERA, this will mean you need to provide the following:

Setup

Once you have gotten your Program Name and Callback URL setup with DAERA you will need to add the authentication integration into your app.

You will need to setup a redirect in your application so that the user is able to login and return a token, for example (in C#):

private const string AuthUrl = "https://reference.dardni.gov.uk/AuthWeb/auth/login"; 
private const string AppName = "DAERA.AOL.WebServices.TestClient";

public IActionResult RedirectToLogin(string appName) => Redirect($"{AuthUrl}/{AppName}/2/");

You will need to add a callback to your application that can receive the token from the DAERA Authentication, similar to below (C#):

private const string TokenKey = "token";

[HttpPost]
public IActionResult Callback(FormCollection formValueCollection)
{
    var tokenString = formValueCollection[TokenKey];
    if (!string.IsNullOrWhiteSpace(tokenString))
    {
        TempData[TokenKey] = formValueCollection[TokenKey];
    }

    return RedirectToAction(nameof(Index));
}

Once you have the token, you can then pass it in your transaction that you send to EasiTrace:

{
  "reference": "my reference",
  "transactionDate": "2019-01-31T22:26:47.075+00:00",
  "type": "REG",
  "speciesCode": "C",
  "propertyIdentifier": "20/002/0001",
  "serviceAuthToken": "...."
  "fields": {
    ...
  },
  "animals": [
    ...
  ]
}

For more information about submitting Transactions see Submitting transactions.