auth via params API Access with Authlogic

Authlogic, my current favorite Ruby-based authentication library and I were in a fight the last couple of days.

I was trying to add token-based, auth_via_params, authentication (vs. login and password) to a project – but Authlogic and I weren’t agreeing on how it should be done.

I had assumed:

@person_session = PersonSession.new(single_access_token => params[:token] )
@person_session.save

Instead Authlogic wanted me to give it a Person first.

@person_session = PersonSession.new(Person.find_by_single_access_token(params[:token]))
@person_session.save