Module: Shutl::Auth

Extended by:
Auth
Included in:
Auth
Defined in:
lib/shutl_auth.rb,
lib/shutl/auth/version.rb,
lib/shutl/auth/access_token_request.rb,
lib/shutl/auth/authenticated_request.rb

Defined Under Namespace

Modules: AuthenticatedRequest Classes: Cache, InternalServerError, InvalidCredentials, InvalidUrl

Constant Summary collapse

VERSION =
"0.8.4"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



15
16
17
# File 'lib/shutl_auth.rb', line 15

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



15
16
17
# File 'lib/shutl_auth.rb', line 15

def client_secret
  @client_secret
end

#urlObject

Returns the value of attribute url.



15
16
17
# File 'lib/shutl_auth.rb', line 15

def url
  @url
end

Instance Method Details

#access_token!Object



8
9
10
# File 'lib/shutl/auth/access_token_request.rb', line 8

def access_token!
  access_token_response!.access_token
end

#access_token_response!Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/shutl/auth/access_token_request.rb', line 12

def access_token_response!
  c = client

  Shutl::NetworkRetry.retry "Authentication Service Error" do
    handling_exceptions do
      Shutl::Auth.logger.debug "executing Rack::OAuth2::Client request"
      c.access_token!
    end
 end
end

#config {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Shutl::Auth)

    the object that the method was called on



17
18
19
# File 'lib/shutl_auth.rb', line 17

def config
  yield self
end

#loggerObject



21
22
23
24
25
# File 'lib/shutl_auth.rb', line 21

def logger
  return ::Rails.logger if Kernel.const_defined?(:Rails)
  return ::Shutl.logger if Shutl.respond_to? :logger
  Logger.new('/dev/null')
end