Class: OAuth2::Grant::Password

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

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_token(username, password, opts = {}) ⇒ Object

Retrieve an access token given the specified client.

Parameters:

  • username
  • password
  • params (Hash)

    additional params

  • opts (Hash) (defaults to: {})

    options



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/oauth2/grant/password.rb', line 15

def get_token(username, password, opts={})
  opts[:params] ||= {}
  opts[:params].merge!({
    :grant_type => grant_type,
    :username   => username,
    :password   => password
  })
  opts[:authenticate] ||= :headers
  method = opts.delete(:method) || :post
  make_request(method, @token_path, opts)
end

#grant_typeObject



5
6
7
# File 'lib/oauth2/grant/password.rb', line 5

def grant_type
  'password'
end