class Stormpath::Oauth::Authenticator

Constants

GRANT_CLASSES_BY_TYPE

Public Class Methods

new(data_store) click to toggle source
  # File lib/stormpath-sdk/oauth/authenticator.rb
6 def initialize(data_store)
7   @data_store = data_store
8 end

Public Instance Methods

authenticate(parent_href, request) click to toggle source
   # File lib/stormpath-sdk/oauth/authenticator.rb
10 def authenticate(parent_href, request)
11   assert_not_nil parent_href, 'parent_href must be specified'
12 
13   clazz = GRANT_CLASSES_BY_TYPE[request.grant_type.to_sym]
14   attempt = @data_store.instantiate(clazz)
15   attempt.set_options(request)
16   href = parent_href + '/oauth/token'
17 
18   @data_store.create(href, attempt, Stormpath::Oauth::AccessTokenAuthenticationResult)
19 end