module Doorkeeper class AccessGrant include Doorkeeper::OAuth::Helpers include Doorkeeper::Models::Scopes belongs_to :application, :class_name => "Doorkeeper::Application", :inverse_of => :access_grants validates :resource_owner_id, :application_id, :token, :expires_in, :redirect_uri, :presence => true before_create :generate_token def self.authenticate(token) where(:token => token).first end private def generate_token # This is wrong! Token should be the id of the AccessGrant class not independently added.... (same as AccessToken) # There should be a way to make it raise an error using the ruby model # self.add('token', UniqueToken.generate) end end end