How can I use a third-party API which has basic authentication (username, password) in Django?


I have one third-party API (a URL). To access that URL I have to give basic authentication which is username and password.

How can I get data from that API using basic authentication in Django?


You can use the Requests package. Something like:

from requests.auth import HTTPBasicAuth
requests.get('', auth=HTTPBasicAuth('user', 'pass'))

Answered By – shilin agre

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published