Forum Discussion

rlgopinath's avatar
rlgopinath
New Contributor
2 years ago

Authenticate to Zephyr using the ZAPI token or username and password

We are trying to use below code for zephyr authentication to be used in selenium automation framework. is this correct code? we are getting invalid api error

 

# Authenticate to Zephyr using the ZAPI token or username and password
auth_url = zephyr_rest_api_url + "/authentication/generateToken"
auth_data = {"accessKey": zephyr_access_key, "secretKey": zephyr_secret_key}
auth_headers = {"Content-Type": "application/json"}
auth_response = requests.post(auth_url, data=json.dumps(auth_data), headers=auth_headers, auth=(zephyr_username, zephyr_password))
auth_token = auth_response.json()["access_token"]
headers = {"Authorization": "Bearer " + auth_token, "Content-Type": "application/json"}

No RepliesBe the first to reply