
{"id":19115,"date":"2022-08-13T20:29:23","date_gmt":"2022-08-13T14:59:23","guid":{"rendered":"https:\/\/valavil.in\/?p=19115"},"modified":"2022-08-13T20:29:23","modified_gmt":"2022-08-13T14:59:23","slug":"program-to-do-basic-authentication-using-requests-module-in-python","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2022\/08\/13\/program-to-do-basic-authentication-using-requests-module-in-python\/","title":{"rendered":"Program to do basic authentication using &#8220;requests&#8221;  module in python"},"content":{"rendered":"\n<pre class=\"wp-block-preformatted\">$python3 basic_authentication.py \nResponse.status_code:401\n$cat basic_authentication.py \n#!\/usr\/bin\/env python3\n\nimport requests\nfrom requests.auth import HTTPBasicAuth\n\nrequests.get('https:\/\/api.github.com\/user', auth=HTTPBasicAuth('user', 'password'))\n\n# requests provides a shorthand for this authentication method\nresponse = requests.get('https:\/\/api.github.com\/user', auth=('user', 'password'))\n\nprint('Response.status_code:'+ str(response.status_code))\n\nif response.status_code == 200:\n\tprint('Login successful :'+response.text)\n\n$  <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$python3 basic_authentication.py Response.status_code:401 $cat basic_authentication.py #!\/usr\/bin\/env python3 import requests from requests.auth import HTTPBasicAuth requests.get(&#8216;https:\/\/api.github.com\/user&#8217;, auth=HTTPBasicAuth(&#8216;user&#8217;, &#8216;password&#8217;)) # requests provides a shorthand for this authentication method response = requests.get(&#8216;https:\/\/api.github.com\/user&#8217;, auth=(&#8216;user&#8217;, &#8216;password&#8217;)) print(&#8216;Response.status_code:&#8217;+ str(response.status_code)) if response.status_code == 200: print(&#8216;Login successful :&#8217;+response.text) $<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19115"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=19115"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19115\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=19115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=19115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=19115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}