Sha256: 14bdb3fd16f1dd694c058b143b1b72604a33efa4d2ac995775ffe7cb96e2908c

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module OAuth2
  module Grant
    # Device Grant
    # @see https://developers.google.com/accounts/docs/OAuth2ForDevices
    class DeviceCode < Base

      def grant_type
        "http://oauth.net/grant_type/device/1.0"
      end

      # Generate the authorization path using the given parameters .
      #
      # @param [Hash] query parameters
      def get_code(opts={})
        opts[:params] ||= {}
        opts[:params][:client_id] = @client_id
        method = opts.delete(:method) || :post
        make_request(method, @device_path, opts)
      end

      # Retrieve an access token given the specified client.
      #
      # @param [Hash] params additional params
      # @param [Hash] opts options
      def get_token(code, opts={})
        opts[:params] ||= {}
        opts[:params].merge!({
          :code       => code,
          :grant_type => grant_type
        })
        opts[:authenticate] ||= :headers
        method = opts.delete(:method) || :post
        make_request(method, @token_path, opts)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oauth2-client-1.1.3 lib/oauth2/grant/device.rb
oauth2-client-1.1.2 lib/oauth2/grant/device.rb
oauth2-client-1.1.1 lib/oauth2/grant/device.rb
oauth2-client-1.1.0 lib/oauth2/grant/device.rb
oauth2-client-1.0.0 lib/oauth2/grant/device.rb