Hi,
I am getting below mentioned response
{"responseStatus":{"status":401,"code":"9159","severity":"ERROR","message":"Token Validation Failed","info":""}}
API Url:
Logs from my program
resourcePath: reports/v1/transactiondata
queryString: apiKey=QM6BVPJH6XNA7RMZGLJG21iNon2ZUrYEA5CDL3sTmKb_-7Xzk
Method : GET
x-pay-token: xv2:1715929972:814a08964509c06f8fc056090767bfc2b9ff2fe6c66f1496251d9e96a4b94814
I am using Nodejs program to generate x-pay-token, but even after so many retries, I am not able to figure out why am I getting "Token Validation Failed"
Please advise.
Hi @saisandeep, Thank you for your question. An agent will get back to you with more information soon. Until then, if any community member knows a solution, feel free to reply to this thread.
@saisandeep wrote:Hi,
I am getting below mentioned response
{"responseStatus":{"status":401,"code":"9159","severity":"ERROR","message":"Token Validation Failed","info":""}}API Url:
Logs from my program
resourcePath: reports/v1/transactiondataqueryString: apiKey=QM6BVPJH6XNA7RMZGLJG21iNon2ZUrYEA5CDL3sTmKb_-7Xzk
Method : GET
x-pay-token: xv2:1715929972:814a08964509c06f8fc056090767bfc2b9ff2fe6c66f1496251d9e96a4b94814
I am using Nodejs program to generate x-pay-token, but even after so many retries, I am not able to figure out why am I getting "Token Validation Failed"
Please advise.
Hello,
I'd be glad to help you troubleshoot the "Token Validation Failed" error you're encountering with the Visa Direct API's transactiondata endpoint. Here are the consolidated insights and potential solutions, combining the best aspects of previous responses and addressing identified issues:
Understanding the Error:
Status Code 401: This indicates an authentication issue. The API is unable to validate the provided credentials (specifically, the x-pay-token).
Potential Causes:
Incorrect Token Generation:
Double-check your Node.js code for any errors in generating the x-pay-token. Ensure you're using the correct algorithm and secret key provided by Visa.
Verify the token format (xv2:<timestamp>:<signature>) and encoding (usually Base64).
Consider using a library or package specifically designed for Visa Direct token generation in Node.js, if available, to streamline the process and reduce potential mistakes.
Expired Token:
The x-pay-token has a limited lifespan (typically a few minutes). If your code generates the token too early before the API call, it might expire by the time the request reaches the server.
Generate the token closer to the API call to minimize the chance of expiration.
Incorrect API Key:
Ensure you're using the correct API key provided by Visa for your sandbox environment. Double-check for typos or errors in the apiKey query parameter.
Network or Server Issues:
Less likely, but there could be temporary network issues or problems on Visa's side. You might want to retry the API call after a short delay, or monitor Visa's developer portal for any known outages.
Debugging Steps:
Log the Generated Token:
Print or log the generated x-pay-token to your console or a log file to verify its format and value.
Simplify Your Code:
If you have a complex Node.js program, try isolating the token generation logic into a simpler test script. This can help pinpoint where the issue might lie.
Use a Tool for Token Validation:
If available, consider using a tool like Postman or a browser developer extension to manually construct the API request with your generated token. This can help isolate your code from potential environment or configuration issues.
Refer to Visa's Documentation:
Carefully review Visa's documentation for the transactiondata endpoint, specifically the authentication requirements and token generation process. Look for any code examples or troubleshooting guides that might be relevant.
Additional Tips:
Clear Sensitive Information:
Avoid logging or sharing your API key or secret key in full. Truncate or redact sensitive parts for security reasons.
Consider Error Handling:
Implement proper error handling in your Node.js program to catch and log the "Token Validation Failed" response from the API. This can provide more details about the problem.
I hope the information may helps you.