0

I want to write the following curl command into python code. Following is the command for requesting some data from the URL.

<user_name> : replace with the username
<api_token> : replace with the token secret key

curl -u <user_name>/token:<api_token> <URL>
  • Does this answer your question? [How do I use basic HTTP authentication with the python Requests library?](https://stackoverflow.com/questions/26745462/how-do-i-use-basic-http-authentication-with-the-python-requests-library) – gre_gor Nov 27 '21 at 08:19
  • @gre_gor No,it doesnt work. – Milind Prajapat Nov 27 '21 at 10:47
  • 1
    "doesnt work" is not a proper problem description. Provide a [mre]. – gre_gor Nov 27 '21 at 11:00
  • @gre_gor I tried the solution posted on the site, none of them worked. All of them returned a 401 Error. I guess when username and password are passed, it interpret it as ```username:password``` but in my case, I want it as ```username/token:password``` – Milind Prajapat Nov 27 '21 at 11:38

1 Answers1

1

We can use requests module:

response = requests.get(<URL>, auth = (f'{<user_name>}/token', <api_token>))