Class: Google::APIClient::RedisStore Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/google/api_client/auth/storages/redis_store.rb

Overview

Deprecated.

Use google-auth-library-ruby instead

Constant Summary collapse

DEFAULT_REDIS_CREDENTIALS_KEY =
"google_api_credentials"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redis, key = nil) ⇒ RedisStore

Initializes the RedisStore object.

Parameters:

  • redis (Object)

    Redis instance

  • key (Object) (defaults to: nil)

    Optional key to store credentials under. Defaults to 'google_api_credentials'


33
34
35
36
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 33

def initialize(redis, key = nil)
  @redis= redis
  @redis_credentials_key = key
end

Instance Attribute Details

#redisObject

Returns the value of attribute redis


24
25
26
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 24

def redis
  @redis
end

Instance Method Details

#load_credentialsHash

Attempt to read in credentials from redis.

Returns:

  • (Hash)

41
42
43
44
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 41

def load_credentials
  credentials = redis.get redis_credentials_key
  JSON.parse(credentials) if credentials
end

#redis_credentials_keyObject


46
47
48
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 46

def redis_credentials_key
  @redis_credentials_key || DEFAULT_REDIS_CREDENTIALS_KEY
end

#write_credentials(credentials_hash) ⇒ Object

Write the credentials to redis.

Parameters:

  • credentials_hash (Hash)

54
55
56
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 54

def write_credentials(credentials_hash)
  redis.set(redis_credentials_key, credentials_hash.to_json)
end