0

I have picked up some work on a headless Drupal 7 site, using services, and service_token.

Where the "normal" service login, as I understand it, uses a cookie to authenticate, Services Token allows authentication by passing a token as the username in a basic auth header.

All appears to work well. But I have been asked to implement "Forgot password", and I am struggling to understand how that flow fits with Services Token.

Any guidance most appreciated.

1

It's already built into the Services module, just enable its corresponding resource then do a POST ?q=[my-endpoint]/user/request_new_password.json and send along a name, e.g.: name=john or an e-mail address: name=john@example.com

  • Thanks Tyler, I have done that. And I have it working with the normal login flow. But the site makes use of services_token, and I can't get it to work with that... Am I missing something? – mediaashley Aug 30 '16 at 11:02
  • I haven't used that module, but perhaps just add the token to the URL query string: ?q=[my-endpoint]/user/request_new_password.json&token=abcdefg&name=john – tyler.frankenstein Aug 30 '16 at 13:00
0

The solutions, a custom endpoint that takes the token as a password.

The problem we had was that the standard services authentication flow relies on cookies and that is a problem/pain when working with AngularJS (apparently).

Hence the use of service_token. An update to the two modules allowed for most of the login and forgot password flow. service_token for auth, and services for forgot password.

To handle the reset (noting that this was not a production site and this was not the most robust of solutions), we added a custom endpoint that took the service_token token as the "current password"

Hope that is of help to others.

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.