Class: Cryptoprocessing::Api::Auth::TokenStore

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptoprocessing/authentication/token_store.rb

Constant Summary collapse

AUTHORIZATION_URI =
'https://accounts.google.com/o/oauth2/auth'
TOKEN_CREDENTIAL_URI =
'https://accounts.google.com/o/oauth2/token'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store) ⇒ TokenStore

Initializes the Storage object.

Parameters:

  • store (Object)

    Storage object



20
21
22
# File 'lib/cryptoprocessing/authentication/token_store.rb', line 20

def initialize(store)
  @store = store
end

Instance Attribute Details

#storeObject

Returns Storage object.

Returns:

  • (Object)

    Storage object.



13
14
15
# File 'lib/cryptoprocessing/authentication/token_store.rb', line 13

def store
  @store
end

Instance Method Details

#credentials_hashHash

Returns with credentials.

Returns:

  • (Hash)

    with credentials



45
46
47
48
49
50
51
52
53
# File 'lib/cryptoprocessing/authentication/token_store.rb', line 45

def credentials_hash
  {
      :authorization_uri => AUTHORIZATION_URI,
      :token_credential_uri => TOKEN_CREDENTIAL_URI,
      :issued_at => authorization.issued_at.to_i,
      :auth_token => '',
      :user_id => '',
  }
end

#load_credentialsObject

Attempt to read in credentials from the specified store.



39
40
41
# File 'lib/cryptoprocessing/authentication/token_store.rb', line 39

def load_credentials
  store.load_credentials
end

#refresh_authorizationObject

refresh credentials and save them to store



33
34
35
# File 'lib/cryptoprocessing/authentication/token_store.rb', line 33

def refresh_authorization
  self.write_credentials
end

#write_credentialsObject

Write the credentials to the specified store.



27
28
29
# File 'lib/cryptoprocessing/authentication/token_store.rb', line 27

def write_credentials
  store.write_credentials(credentials_hash)
end