The Anubhav portal was launched in March 2015 at the behest of the Hon'ble Prime Minister for retiring government officials to leave a record of their experiences while in Govt service .
import requests
# Replace this with your actual access token
ACCESS_TOKEN = "your_actual_access_token_here"
# Set up authorization headers
headers = {
"Authorization": f"Bearer {ACCESS_TOKEN}"
}
# Send the GET request
response = requests.get("https://api.example.com/profile", headers=headers)
# Check for errors before parsing JSON
if response.ok:
print(response.json())
else:
print(f"Request failed with status code {response.status_code}")
print(response.text)
You can also use Basic Auth:
import requests
from requests.auth import HTTPBasicAuth
# Replace with your actual username and password
USERNAME = "your_username_here"
PASSWORD = "your_password_here"
# Send GET request with Basic Authentication
response = requests.get(
"https://api.example.com",
auth=HTTPBasicAuth(USERNAME, PASSWORD)
)
# Check response status and handle results
if response.ok:
print("Request succeeded!")
print(response.json()) # or response.text if not JSON
else:
print(f"Request failed with status code {response.status_code}")
print(response.text)
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Answer:
You can use the requests:
You can also use Basic Auth: