Bearer {token}
headers['Authorization'] = f"Bearer {token}"
api = WebexTeamsAPI(access_token=token)
X-Cisco-Meraki-API-Key
with the API key in itheaders['X-Cisco-Meraki-API-Key'] = {api_key}
X-Auth-Token
on subsequent requestsimport requests
from requests.auth import HTTPBasicAuth
username = "devnetuser"
password = "Cisco123!"
hostname = "sandboxdnac2.cisco.com"
auth = HTTPBasicAuth(username, password)
login_url = f"https://{hostname}/dna/system/api/v1/auth/token"
resp = requests.post(login_url, headers=headers, auth=auth)
token = resp.json()['Token']
headers['X-Auth-Token'] = token
from dnacentersdk import api
dnac = api.DNACenterAPI(username="devnetuser",
password="Cisco123!",
base_url="https://sandboxdnac2.cisco.com")
from intersight_auth import IntersightAuth
auth = IntersightAuth(secret_key_filename=key_file, api_key_id=api_key_id)
requests.get("https://intersight.com/api/v1/compute/PhysicalSummaries", auth=auth)
api_instance = IntersightApiClient(
"https://intersight.com/api/v1",
private_key="SecretKey.txt",
api_key_id = "5eaf2f437564612d309e379a/5eaf2f437564612d309e37a7/5ef564117564612d33d47ce1"
)
login_body = f'<aaaLogin inName="{username}" inPassword="{password}"/>'
headers = {"Content-Type": "application/x-www-form-urlencoded"}
resp = requests.post(url=url, headers=headers, data=login_body, verify=False)
Login response:
<aaaLogin cookie="" response="yes" '
'outCookie="1593347478/7bdd8f29-7dbc-42e4-b088-f59ac09e8488" '
'outRefreshPeriod="600" '
'outPriv="aaa,admin,ext-lan-config,ext-lan-policy,ext-lan-qos,ext-lan-security,ext-san-config,ext-san-policy,ext-san-security,fault,operations,pod-config,pod-policy,pod-qos,pod-security,read-only" '
'outDomains="org-root" outChannel="noencssl" outEvtChannel="noencssl" '
'outSessionId="" outVersion="4.1(2c)" outName=""> </aaaLogin>
from ucsmsdk.ucshandle import UcsHandle
handle = UcsHandle(hostname, username, password)
handle.login()
access_token
which must be set in an Authorization header on any subsequent requests in the format Bearer [access-token]
token_payload = {"grant_type": "password",
"username": "admin",
"password": "Cisco1234"}
headers = {"Content-Type":"application/json", "Accept": "application/json"}
url = f"https://{hostname}/api/fdm/latest/fdm/token"
resp = requests.post(url=url,
headers=headers,
json=token_payload,
verify=False)
token = resp.json()['access_token']
headers['Authorization'] = f"Bearer {token}"
auth
argument of the requests moduleauth = ("developer", "C1sco12345")
get_headers = {"Accept": "application/yang-data+json"}
get_rte_resp = requests.get(
url,
headers=get_headers,
auth=auth,
verify=False
)