Migrated from Redmine #1296 | Author: Tadeáš Černý
Status: Feedback | Priority: High, I’m very impatient | Created: 2024-10-28
Hello,
I’m currently facing an issue with the SimplyBook API while trying to create a booking via the book method in the API. I’ve implemented the authentication process as per the documentation, and I’m able to successfully retrieve an authorization token by calling the getToken method. However, when I attempt to use this token for subsequent requests to endpoints like /admin/clients or /admin/bookings, I consistently receive a 401 Unauthorized error.
Here’s a summary of my setup and the issue:
Token Retrieval: I successfully retrieve the token at the beginning of my application using the getToken method. The token is returned correctly and stored for future use.
Booking Process:
Before creating a booking, I attempt to check if a client already exists in the system by calling the /admin/clients endpoint with the token in the X-Token header.
If the client does not exist, I then attempt to create a new client.
Finally, I call the /admin/bookings endpoint to create the booking.
Problem: Every time I send requests to the /admin/clients or /admin/bookings endpoints with the retrieved token, the response returns a 401 Unauthorized error. This error occurs even though the token was freshly retrieved and passed in the request headers as specified in the documentation.
Possible Cause: I suspect the issue may be due to the token becoming invalid too quickly or being affected by multiple token retrievals in the same session. However, I have also tried storing the token and using it consistently without repeated retrievals, but the issue persists.
Here’s a snippet of the headers I’m using for these requests:
headers: {
“Content-Type”: “application/json”,
“X-Company-Login”: companyLogin, // My company login
“X-Token”: token // Token retrieved from getToken method
}
Could you please advise on what might be causing this issue? Is there a specific way to manage token retrieval and reusability that I might be overlooking, or could there be any server-side settings affecting the token validity?
Thank you for your assistance.