Class: OAuth2::Grant::DeviceCode

Inherits:
Base
  • Object
show all
Defined in:
lib/oauth2/grant/device.rb

Overview

Device Grant

Instance Attribute Summary

Attributes inherited from Base

#authorize_path, #client_id, #client_secret, #connection, #device_path, #host, #token_path

Instance Method Summary collapse

Methods inherited from Base

#initialize, #make_request

Methods included from UrlHelper

#build_url, #generate_timestamp, #generate_urlsafe_key, http_basic_encode, #to_query

Constructor Details

This class inherits a constructor from OAuth2::Grant::Base

Instance Method Details

#get_code(opts = {}) ⇒ Object

Generate the authorization path using the given parameters .



14
15
16
17
18
19
# File 'lib/oauth2/grant/device.rb', line 14

def get_code(opts={})
  opts[:params] ||= {}
  opts[:params][:client_id] = @client_id
  method = opts.delete(:method) || :post
  make_request(method, @device_path, opts)
end

#get_token(code, opts = {}) ⇒ Object

Retrieve an access token given the specified client.



25
26
27
28
29
30
31
32
33
34
# File 'lib/oauth2/grant/device.rb', line 25

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

#grant_typeObject



7
8
9
# File 'lib/oauth2/grant/device.rb', line 7

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