Sha256: 0bb1f7d1f25fe45269688ac48f886b04a56dfc5837634114b0cdb0e3f1f39c99

Contents?: true

Size: 639 Bytes

Versions: 27

Compression:

Stored size: 639 Bytes

Contents

class Oauth2Verifier < OauthToken
  validates_presence_of :user
  attr_accessor :state

  def exchange!(params={})
    OauthToken.transaction do
      token = Oauth2Token.create! :user=>user,:client_application=>client_application, :scope => scope
      invalidate!
      token
    end
  end

  def code
    token
  end

  def redirect_url
    callback_url
  end

  def to_query
    q = "code=#{token}"
    q << "&state=#{URI.escape(state)}" if @state
    q
  end

  protected

  def generate_keys
    self.token = OAuth::Helper.generate_key(20)[0,20]
    self.expires_at = 10.minutes.from_now
    self.authorized_at = Time.now
  end

end

Version data entries

27 entries across 9 versions & 4 rubygems

Version Path
houston-oauth-plugin-0.5.1 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb
houston-oauth-plugin-0.5.1 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
houston-oauth-plugin-0.5.1 generators/oauth_provider/templates/oauth2_verifier.rb
panjiva-oauth-plugin-0.4.1 generators/oauth_provider/templates/oauth2_verifier.rb
panjiva-oauth-plugin-0.4.1 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb
panjiva-oauth-plugin-0.4.1 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.5.1 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.5.1 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.5.1 generators/oauth_provider/templates/oauth2_verifier.rb
oauth-plugin-0.5.0 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.5.0 generators/oauth_provider/templates/oauth2_verifier.rb
oauth-plugin-0.5.0 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb
oauth-provider-0.5.0rc1 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb
oauth-provider-0.5.0rc1 generators/oauth_provider/templates/oauth2_verifier.rb
oauth-provider-0.5.0rc1 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.4.1 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.4.1 generators/oauth_provider/templates/oauth2_verifier.rb
oauth-plugin-0.4.1 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.4.0 lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb
oauth-plugin-0.4.0 lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb