Reply

NetMRI REST API - How to authenticate without using cookies

Authority
Posts: 36
3236     0

Hello,

We're busy setting up syncronisation between one of our databases and the list feature of NetMRI to push some info about our locations so we can use it in our script. For this we use the REST API of NetMRI because it's the only way to interface with the system from outside. But we bump into an issue here. The tool we're using (PowerCenter from Informatica) doesn't support the way of authenticating in NetMRI. It can't call /api/authenticate before doing other calls because it can't handle the cookies that are returned. (It handles REST as being stateless)

Are there any undocumented ways to authenticate?

Can we pass headers or fields in every REST call to authenticate? Like basic authentication HTTP headers for example? Or maybe even a client certificate?

HTTP Basic authentication

Adviser
Posts: 353
3237     0

HTTP Basic authentication works as well. It's just slower, especially if it has to go out to AD for every call.

 

Indeed that works.

Authority
Posts: 36
3237     0

Indeed that works.

I tested it before but a browser appears to only send the basic authentication header when he receives a challenge. The same with WGET, you have to add the --auth-no-challenge option to force it so send the header.

Here is a sinppet from my

Adviser
Posts: 406
3237     0

Here is a sinppet from my python code:

#!/usr/bin/python

# -*- coding: utf-8 -*-

__author__ = 'Sif Baksh @ Infoblox'

 

import requests

import json

 

netmri = "10.10.10.1"

username = "sifbaksh"

password = "testpw"

 

url = "https://"

object_type = "/api/2.6/devices/index"

 

data = requests.get(url + netmri + object_type, verify=False, auth=(username, password))

 

json_input = data.text

 

try:

            decoded = json.loads(json_input)

terminal

            for entry in decoded['devices']:

                        print entry['DeviceName']

 

except (ValueError, KeyError, TypeError):

    print "JSON format error"

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh
Showing results for 
Search instead for 
Do you mean 

Recommended for You