Nishat sAyyed
Nishat sAyyed

Reputation: 109

RightMove Datafeed API Auth - Axios TLS auth

I am working on a module that requires me to feed data into RightMove using their API. But before that, it requires mutual authentication to verify the data feeder - which uses some certificates and keys.

I received the following file formats from RightMove:

I also have a passphrase provided by RightMove to use with these (or one of these) files.

Now I have to use these files to auth with RightMove but I am not sure what file does what. I am using Axios with Node.js

Can someone help me form an axios call that would make use of these files for auth?

Upvotes: 0

Views: 1018

Answers (2)

Nishat sAyyed
Nishat sAyyed

Reputation: 109

So I solved it using the p12 file and the passphrase only. The JKS file and PEM file were not needed.

const httpsAgent = new https.Agent({
   pfx: fs.readFileSync('/path/to/p12/file'),
   passphrase: '<your-passphrase>',
})
await axios.post(url, data, { headers, httpsAgent })

Upvotes: -2

razki
razki

Reputation: 1229

https://media.rightmove.co.uk/ps/pdf/guides/adf/Rightmove_Real_Time_Datafeed_Specification.pdf

So I've taken a look at the documentation for the RightMove API and it says on page 5 that they provide you with all three files depending on the development environment.

So for this we will make use of the .pem file.

const https = require('https')
const fs = require('fs')
const axios = require('axios')

const key = fs.readFileSync('./key.pem')
const ca = fs.readFileSync('./ca.crt')

const url = 'https://adfapi.rightmove.co.uk/'

const httpsAgent = new https.Agent({
    rejectUnauthorized: true, // Set to false if you dont have the CA
    key,
    ca,
    passphrase: 'YYY', // Would recommend storing as secret
    keepAlive: false,
})

const axiosInstance = axios.create({ headers: { 'User-Agent': 'rightmove-datafeed/1.0' }, httpsAgent })

axiosInstance.get(url, { httpsAgent })

I noticed that the documentation said that some of the API's in use with RightMove you are required to set a custom User-Agent. The documentation mentions that they have JSON or XML schemas available for download here. You can also see example responses.

Because you're most likely going to be making a number of calls I've created an axios instance, this means that you will only have to set these options once for all requests.

Upvotes: 0

Related Questions