Search code examples
pythonauthenticationpython-requestshttp-authentication

How to access datahug API via HTTP Authentication?


In Datahug's documentation, it states, 'Authentication is performed using HTTP Basic Authentication - A Datahug username and password will be required in order to access the API.'

As a result, I've tried the below (with my username and password defined)

import requests
from requests.auth import HTTPBasicAuth

url = 'https://api.datahug.com/Contact/'
l = requests.get(url,auth=HTTPBasicAuth(username,password)

But I receive the following error:

<Response [401]>

Am I doing something wrong here?

I've also tried the following:

import requests
from requests.auth import HTTPBasicAuth

url = "https://api.datahug.com/Contact/test@test.com"
l = requests.get(url,auth=(username,password))

Solution

  • I've tracked the issue down to the Datahug Edition your account was configured to. It was CRM Only which at the moment doesn't allow API access. I've changed the account Edition to Full which will also give you access to the web app and you will also be able to make api calls.

    You should now get a valid response when you make API calls.