Class: D2L::Valence::AuthTokens
- Inherits:
-
Object
- Object
- D2L::Valence::AuthTokens
- Defined in:
- lib/d2l/valence/auth_tokens.rb
Overview
AuthTokens
Class to generate authentication tokens for D2L Valance API calls
Constant Summary collapse
- APP_ID_PARAM =
'x_a'.freeze
- USER_ID_PARAM =
'x_b'.freeze
- SIGNATURE_BY_APP_KEY_PARAM =
'x_c'.freeze
- SIGNATURE_BY_USER_KEY_PARAM =
'x_d'.freeze
- TIMESTAMP_PARAM =
'x_t'.freeze
Instance Method Summary collapse
-
#adjusted_timestamp ⇒ Integer
Generates a timestamp with time skew between server and client taken into consideration.
-
#generate ⇒ Hash
Generates the auth tokens as a Hash for inclusion in the final URI query string.
-
#initialize(request:) ⇒ AuthTokens
constructor
A new instance of AuthTokens.
Constructor Details
#initialize(request:) ⇒ AuthTokens
Returns a new instance of AuthTokens.
13 14 15 16 17 |
# File 'lib/d2l/valence/auth_tokens.rb', line 13 def initialize(request:) @call = request @user_context = @call.user_context @app_context = @user_context.app_context end |
Instance Method Details
#adjusted_timestamp ⇒ Integer
Generates a timestamp with time skew between server and client taken into consideration
32 33 34 |
# File 'lib/d2l/valence/auth_tokens.rb', line 32 def @adjusted_timestamp ||= Time.now.to_f.to_i + @user_context.server_skew end |
#generate ⇒ Hash
Generates the auth tokens as a Hash for inclusion in the final URI query string
21 22 23 24 25 26 27 |
# File 'lib/d2l/valence/auth_tokens.rb', line 21 def generate @tokens = {} add_app_tokens add_user_tokens @tokens end |