Module: Applidget::Oauth2

Defined in:
lib/applidget/oauth2.rb,
lib/applidget/oauth2/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#api_response(options, params) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/applidget/oauth2.rb', line 33

def api_response(options, params)
  @options = options
  @params = params
  if check_csrf
    @access_token = build_access_token
    @access_token.get(@options[:api]).parsed
  end
end

#request_uri(options) ⇒ Object

Any Oauth2 protocol with Applidget Accounts should be implemented by inheriting from this controller. You should provide a method ‘@options’ that defines a hash with the right parameters, e.g. :

def @options
  {
    model: "guest",
    api: "/api/v1/me.json",
    request_params: { hd: params[:hd], auth: params[:auth], scope: "public" },
    callback_url: generic_url_from callback_guests_auth_applidget_accounts_path,
    client_id: "785439208457639203847539208374",
    client_secret: "7468539205733452975829047568892"
  }
end

You should also override callback method : the parsed response from the api will be given by calling the super method, e.g. :

def callback
  guest_hash = super
  # your code ...
end


28
29
30
31
# File 'lib/applidget/oauth2.rb', line 28

def request_uri(options)
  @options = options
  client.auth_code.authorize_url({:redirect_uri => @options[:callback_url]}.merge(request_params))
end