Class: OAuth2::Strategy::Password

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

Overview

The Resource Owner Password Credentials Authorization Strategy

See Also:

Instance Method Summary (collapse)

Methods inherited from Base

#authorize_params, #client_params, #initialize

Constructor Details

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

Instance Method Details

- (Object) authorize_url

Not used for this strategy

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/oauth2/strategy/password.rb', line 12

def authorize_url
  raise NotImplementedError, "The authorization endpoint is not used in this strategy"
end

- (Object) get_token(username, password, params = {})

Retrieve an access token given the specified End User username and password.

Parameters:

  • username (String)

    the End User username

  • password (String)

    the End User password

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

    additional params



21
22
23
24
25
26
# File 'lib/oauth2/strategy/password.rb', line 21

def get_token(username, password, params={})
  params = {  'grant_type'  => 'password',
              'username'    => username,
              'password'    => password }.merge(client_params).merge(params)
  OAuth2::AccessToken.from_token_params(@client, params)
end