Rika Das
Rika Das

Reputation: 123

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?

Upvotes: 0

Views: 657

Answers (1)

shilin agre
shilin agre

Reputation: 76

You can use the Requests package. Something like:

from requests.auth import HTTPBasicAuth
requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass'))

Upvotes: 2

Related Questions