I have a rails API and a rails client app that communicate with each other via ActiveResource
. This works great until I need to pass a unique token with each ActiveResource
request to authenticate the user. From what I understand, the ActiveResource
token gets set at the class level and cannot be easily changed, which is obviously a problem if I want people to be passing in their unique session token after they are authenticated.
Here is the flow that I am trying to implement:
- User submits credentials on Client app.
- Client app transmits credentials to API.
- API verifies credentials via Devise and returns an auth token.
- Client receives auth token and saves in session.
- All subsequent requests from Client include the auth token.
- API authenticates all requests with the included auth token.
There are many different posts on SO and Github about this. Some say that it simply cannot be done, others say that you can force it, but there are issues with threading.
How can I accomplish what I'm trying to do without losing the huge benefits that ActiveResource provides?