You do this by passing in an extra param, and choosing the model you want to authenticate based on that param. This is similar to gdonato's answer, but scopes in doorkeeper are better used for managing which permissions are being given to the authenticated app (i.e. "Give this app permission to read X and write Y on your behalf").
Here's what I'm using
resource_owner_from_credentials do |routes|
if params[:user_type].present?
case params[:user_type]
when 'user'
u = User.find_for_database_authentication(email: params[:email])
when 'employer'
u = Employer.find_for_database_authentication(email: params[:email])
when 'admin'
u = Administrator.find_for_database_authentication(email: params[:email])
end
end # I don't want a default auth user_type, so no 'else' block for me
user if user && user.valid_password?(params[:password])
end
Note that if you were to do this using scopes instead of a param that doorkeeper isn't already using for something else, you'll have to configure the scopes like:
# These are found in doorkeeper.rb, but they're commented by default.
# You would use whatever scopes you're wanting to check
default_scopes :public
optional_scopes :write, :update
Using scope as a param to differentiate between User and Admin might work without jiggering default_scopes or optional_scopes in doorkeeper.rb, but only as a side effect of the scoping that doorkeeper expects.