Sha256: efb3da45fe03e6389185c8e31a3e569f614ac0c294211457dc30f9c3b7395bfe

Contents?: true

Size: 906 Bytes

Versions: 57

Compression:

Stored size: 906 Bytes

Contents

module Bearcat
  class Client < Footrest::Client
    module OAuth2

      def auth_redirect_url(client_id, redirect_uri, scopes = nil, response_type='code')
        fullpath('login/oauth2/auth')
        uri = URI.parse(fullpath('login/oauth2/auth'))
        query = [
          ['client_id', client_id],
          ['redirect_uri', redirect_uri],
          ['response_type', response_type]
        ]
        query << ['scopes', scopes] if scopes
        uri.query = URI.encode_www_form(query)
        uri.to_s
      end

      def retrieve_token(client_id, redirect_url, client_secret, code)
        body = post('/login/oauth2/token', {
          client_id: client_id,
          redirect_url: redirect_url,
          client_secret: client_secret,
          code: code
        })
        config[:token] = body['access_token']
        set_connection(config)
        config[:token]
      end

    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
bearcat-1.1.1 lib/bearcat/client/o_auth2.rb
bearcat-1.1.0 lib/bearcat/client/o_auth2.rb
bearcat-1.0.28 lib/bearcat/client/o_auth2.rb
bearcat-1.0.27 lib/bearcat/client/o_auth2.rb
bearcat-1.0.26 lib/bearcat/client/o_auth2.rb
bearcat-1.0.25 lib/bearcat/client/o_auth2.rb
bearcat-1.0.24 lib/bearcat/client/o_auth2.rb
bearcat-1.0.23 lib/bearcat/client/o_auth2.rb
bearcat-1.0.22 lib/bearcat/client/o_auth2.rb
bearcat-1.0.21 lib/bearcat/client/o_auth2.rb
bearcat-1.0.20 lib/bearcat/client/o_auth2.rb
bearcat-1.0.19 lib/bearcat/client/o_auth2.rb
bearcat-1.0.18 lib/bearcat/client/o_auth2.rb
bearcat-1.0.17 lib/bearcat/client/o_auth2.rb
bearcat-1.0.16 lib/bearcat/client/o_auth2.rb
bearcat-1.0.15 lib/bearcat/client/o_auth2.rb
bearcat-1.0.14 lib/bearcat/client/o_auth2.rb
bearcat-1.0.13 lib/bearcat/client/o_auth2.rb
bearcat-1.0.12 lib/bearcat/client/o_auth2.rb
bearcat-1.0.11 lib/bearcat/client/o_auth2.rb