0

I seem to be stuck in authenticating my credentials for a RESTful call with emc vplex

I am just a beginner in python, any suggestions would be helpful.

    import requests,json
    from requests.packages.urllib3.exceptions import InsecureRequestWarning
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
    query_headers = {'content-type': 'application/json', 'accept': 
    'application/json', 'auth':('username', 'password')}

    test=requests.get('https://190.xx.xx.xx/vplex/cluster-
    contexts',verify=False,headers=query_headers)
    print test

So when i pass in the correct credentials in auth i get output as Response [401]

,Error 401 means my authentication has failed, not sure if i am passing it correctly in the dictionary.

1
  • it should be information in documentation on server. it can be authorization or it has to use string 'username:password' encoded in base64. requests may use argument auth= Commented Dec 15, 2017 at 5:32

1 Answer 1

1

For Basic Authentication use the auth parameter (not in headers), example:

query_headers = {'content-type': 'application/json', 'accept': 'application/json'}
test = requests.get(
    'https://190.xx.xx.xx/vplex/cluster-contexts', 
    auth=('username', 'password'), 
    verify=False, 
    headers=query_headers
)
Sign up to request clarification or add additional context in comments.

1 Comment

it did not work, maybe the application i am trying to access is not accepting this format. linux curl worked when i used os.system(). Thank you for your suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.