Sha256: be58ebfbc8c7f445ccb7df7373b13ac7a706599bbb0ff79fc28b07e9fecdb060

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module OAuth2Client
  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

1 entries across 1 versions & 1 rubygems

Version Path
oauth2-client-2.0.0 lib/oauth2-client/grant/device.rb