Sha256: fc49ffbc2a124aa0891070fc9da99fc88d3c3d25bd5eedac6a1e9270c4435b41

Contents?: true

Size: 959 Bytes

Versions: 15

Compression:

Stored size: 959 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

15 entries across 15 versions & 1 rubygems

Version Path
sorcery-0.16.4 lib/sorcery/protocols/oauth2.rb
sorcery-0.16.3 lib/sorcery/protocols/oauth2.rb
sorcery-0.16.2 lib/sorcery/protocols/oauth2.rb
sorcery-0.16.1 lib/sorcery/protocols/oauth2.rb
sorcery-0.15.1 lib/sorcery/protocols/oauth2.rb
sorcery-0.16.0 lib/sorcery/protocols/oauth2.rb
sorcery-0.15.0 lib/sorcery/protocols/oauth2.rb
sorcery-0.14.0 lib/sorcery/protocols/oauth2.rb
sorcery-0.13.0 lib/sorcery/protocols/oauth2.rb
sorcery-0.12.0 lib/sorcery/protocols/oauth2.rb
sorcery-0.11.0 lib/sorcery/protocols/oauth2.rb
sorcery-0.10.3 lib/sorcery/protocols/oauth2.rb
sorcery-0.10.2 lib/sorcery/protocols/oauth2.rb
sorcery-0.10.1 lib/sorcery/protocols/oauth2.rb
sorcery-0.10.0 lib/sorcery/protocols/oauth2.rb