0

Sorry for asking very basic question. First time I am using REST API. I tried to get answer to this question on google. But I am unable to get any such.

I need to login into a website using password based authentication using REST API and Python. I dont want to use selenium or some other tools for this purpose due to company policy.

Website Name : https://www.test.com
Username : admin
Password : test@123

Any clue/idea on proceding further please?

2
  • Can you give us a little more information about the authentication? Do you need to send a simple POST Request to the url with the Username and Password? Is it using HTTP Basic Authentication? Commented Oct 27, 2016 at 7:18
  • @Maurice I need to use simple password based / HTTP basic authentication. Just I want to login into this website for doing further actions. Commented Oct 27, 2016 at 7:22

2 Answers 2

1

Try to use Google chrome REST client extension or postman.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. Will try use the POSTMAN as you said.
0

If you need to issue requests and authenticate yourself using HTTP Basic Authentication, this example from the docs should help:

Use of Basic HTTP Authentication:

import urllib.request

# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='PDQ Application',
                          uri='https://mahler:8092/site-updates.py',
                          user='klem',
                          passwd='kadidd!ehopper')
opener = urllib.request.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)
urllib.request.urlopen('http://www.example.com/login.html')

For more complex usage scenarios I suggest using the httplib2. A great introduction to that is here.

Comments

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.