VMware Cloud Community
Phil_K
Enthusiast
Enthusiast

vROPS REST API Python 3.3 Authentication Issues

Hello all,

I'm getting a blue font: HTTP Error 401: Unauthorized

 

I'm uing the following code:

    import urllib.parse
    import urllib.request
    import urllib.response
   
    userName = "username"
    passWord  = "password"
    top_level_url = "https://vrops/suite-api/api/resources?adapterKind=EP%20Ops%20Adapter"
   
    # create an authorization handler
    p = urllib.request.HTTPPasswordMgrWithDefaultRealm()
    p.add_password(None, top_level_url, userName, passWord);
   
    auth_handler = urllib.request.HTTPBasicAuthHandler(p)
   
    opener = urllib.request.build_opener(auth_handler)
   
    urllib.request.install_opener(opener)
   
    try:
        result = opener.open(top_level_url)
        messages = result.read()
        print (messages)
    except IOError as e:
        print (e)
 

The url above returns the results I'm looking for when pasted into a browser with the correct username and password for the vrops server. So I know if the username and password in the code match my vrops server credentials then that isn't the problem. I'm thinking it has to do with proper headers and trusting the x509 certificate.

Basically I'm at a loss here. I see that the only support for this is the 2.7.x python versions. The Nagini Module in the python documentation for the vrops suite seems rather involved for what I'm trying to do and there is no 3.x support.

Any help would be appreciated!

Thank you.

0 Kudos
0 Replies