Closed cimm closed 6 years ago
I can assign the API key as shown in the documentation:
Streak.api_key = 'secret_key' # do something with the API
problem is this seems to be scoped per method. If I set the key in an initializer it will be lost by the time I call the save method below.
save
class Something def initializer Streak.api_key = 'secret_key' end def save # do something with the API, API key no longer set end end
Is there a way to set the API key without assigning the key in each method separately, in an environment variable or configuration file for example?
@cimm Try adding the key to an ENV variable. I used figaro and it works perfectly.
@cimm You need to change initializer to initialize.
I can assign the API key as shown in the documentation:
problem is this seems to be scoped per method. If I set the key in an initializer it will be lost by the time I call the
save
method below.Is there a way to set the API key without assigning the key in each method separately, in an environment variable or configuration file for example?