
ELHADIALLO asked a question.
Hello everyone,
I'm encountering a problem while attempting to authenticate with a specific API. After following the official documentation to establish a connection and sending an authentication request using Python's 'requests' library, I consistently receive a 400 error with the following message: '{"error": {"code": "400.002.002", "description": "Cookie Missing"}}'.
Here is a simplified snippet of my code:
'''python
import requestsimport jsonCharger les paramètres à partir du fichier JSONs = json.load(open("settings.json", "r", encoding="utf-8"))
Extraire le nom d'utilisateur et le mot de passeusername = s['REVENERA']['USER']password = s['REVENERA']['PASSWORD']
Extract header valuescontent_type = s['headers']['Content-Type']rui_client = s['headers']['RUI-Client']rui_client_version = s['headers']['RUI-Client-Version']origin = s['headers']['Origin']
user = { "user": username, "password": password}
Setup the headers dictionaryheaders = { "Content-Type": content_type, "RUI-Client": rui_client, "RUI-Client-Version": rui_client_version, "Origin": origin }
URL d'authentification de l'APIURL = "https://analytics-api.revenera.com/v3/auth/web "URL_V3 = "https://api.revulytics.com/auth/login "
Création d'une session pour maintenir les cookieswith requests.Session() as session: Faire la requête d'authentification avec les en-têtes et le corps corrects response = session.post(URL, json=user, headers=headers) print(response.cookies)
Vérifiez la réussite de l'authentification if response.ok: print("Authentification réussie") L'ID de session et éventuellement d'autres données peuvent être extraits ici session_id = response.json().get("sessionId") print("ID de session :", session_id) else: print(f"Échec de l'authentification: {response.status_code} - {response.text}")
Exécuter la fonction d'authentification (Cette ligne sera décommentée dans le script final) authenticate_and_execute()
'''
I ensure the session is initiated, and all headers required by the documentation are included. However, the error seems to indicate a missing cookie in my request, although the documentation does not explicitly mention the need for such a cookie for authentication.
Has anyone encountered this type of error before? Is there an additional step or a specific header I might have missed to transmit or receive the required cookie?
Any help or suggestion would be greatly appreciated.
Thank you in advance for your support.
Hi @ELHADIALLO ,
There is an additional step required, and we will update the documentation accordingly. Since most of our team is on holiday due to the region's public holiday schedule, we will be able to assist you by end of this week or early next week. In the meantime, could you please create a support ticket? https://community.revenera.com/s/Usage-Intelligence-Knowledge/How-to-Create-a-Support-Ticket-for-Usage-Intelligence142952
Thank you,
Bhargava
Hello @BhargavaNagaraj ,
I have the same question - can you please update the documentation or let us know here what's missing?
Regards
Jens
We have updated the v3 API documentation with additional instructions required for authentication.
Thanks