2

I can't log in consistently via Services 3 in Drupal 7.

POST http://<mydrupaldomain>/services/user/login.json
{
"username":"admin",
"password":"password"
}
  • The first time I make this request I get a session name and id back. Which is what I want. I use the session information to make successive calls such as update user.
  • The second time I make this request the response comes back as HTML for the login screen.
  • The third time I get

401 Unauthorized: Access denied for user anonymous

  • And at the forth time I get am able to login again with a NEW session name and id.

I make these requests within seconds of each other. I will have an application which will be making multiple API calls to Drupal per second. This includes creating a user and updating a user both of which requires that I get a user session id in order for the request to be served by the API.

Questions: Why the inconsistent behavior? On each login attempt I expected to get either a new session info back or, if the user is already logged in, the current session.

What is the proper way of retrieving and handling sessions when making multiple calls to the Services API?

  • In /admin/structure/services/list/auth do you have checked session authentication checked? that happen to me once..someone unchecked by mistake and I have to checked again and clear the cache? – cayerdis Oct 11 '12 at 17:39
  • HI @cayerdis Yes, I have it checked. – rexposadas Oct 11 '12 at 18:02
2

Apparently the Services module submits a form in order to log a user in. I expected /login to purely go through the backend.

Having said that, I disabled a module which hooked into my login form and now I am getting the expected results.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.