Class: Oauth2Verifier

Inherits:
OauthToken
  • Object
show all
Defined in:
lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb,
lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OauthToken

#authorized?, #invalidate!, #invalidated?

Instance Attribute Details

#stateObject

Returns the value of attribute state


3
4
5
# File 'lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb', line 3

def state
  @state
end

Instance Method Details

#codeObject


13
14
15
# File 'lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb', line 13

def code
  token
end

#exchange!(params = {}) ⇒ Object


5
6
7
8
9
10
11
# File 'lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb', line 5

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

#redirect_urlObject


17
18
19
# File 'lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb', line 17

def redirect_url
  callback_url
end

#to_queryObject


21
22
23
24
25
# File 'lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb', line 21

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