Sha256: 76b6d707d3a46826adfa61045ed3d19c90380b68a71ea10fca8688f4d6a54a9d

Contents?: true

Size: 961 Bytes

Versions: 5

Compression:

Stored size: 961 Bytes

Contents

require 'oauth2'

module Sorcery
  module Protocols
    module Oauth2

      def oauth_version
        '2.0'
      end

      def authorize_url(options = {})
        client = build_client(options)
        client.auth_code.authorize_url(
          redirect_uri: @callback_url,
          scope: @scope,
          display: @display,
          state: @state
        )
      end

      def get_access_token(args, options = {})
        client = build_client(options)
        client.auth_code.get_token(
          args[:code],
          {
            redirect_uri: @callback_url,
            parse: options.delete(:parse)
          },
          options
        )
      end

      def build_client(options = {})
        defaults = {
          site: @site,
          ssl: { ca_file: Sorcery::Controller::Config.ca_file }
        }
        ::OAuth2::Client.new(
          @key,
          @secret,
          defaults.merge!(options)
        )
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
sorcery-0.9.1 lib/sorcery/protocols/oauth2.rb
sorcery-0.9.0 lib/sorcery/protocols/oauth2.rb
cbsorcery-0.8.6 lib/sorcery/protocols/oauth2.rb
cb-sorcery-0.8.6 lib/sorcery/protocols/oauth2.rb
sorcery-0.8.6 lib/sorcery/protocols/oauth2.rb