Sha256: 38eb56db3ce94850c28a4a8ea30dbe6708073c7649cd261a599d2f108987501a

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

module Warden
  module Oauthed
    module Oauth
      class Proxy
        attr_accessor :client_id, :secret, :scopes, :oauth_domain, :callback_url
        def initialize(client_id, secret, scopes, oauth_domain, callback_url)
          @client_id, @secret, @scopes, @oauth_domain, @callback_url = client_id, secret, scopes, oauth_domain, callback_url
        end

        def ssl_options
          { version: :TLSv1 }
        end

        def client
          @client ||= OAuth2::Client.new(@client_id, @secret,
            ssl: ssl_options,
            site: oauth_domain,
            authorize_url: '/oauth/authorize')
        end

        def api_for(code)
          client.auth_code.get_token(code, :redirect_uri => callback_url)
        end

        def authorize_url
          client.auth_code.authorize_url(
            :scope        => scopes,
            :redirect_uri => callback_url
          )
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
warden-oauthed-0.0.3 lib/warden-oauthed/proxy.rb
warden-oauthed-0.0.2 lib/warden-oauthed/proxy.rb