Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

store and read api key from local file #116

Closed
ulf1 opened this issue Aug 24, 2018 · 1 comment
Closed

store and read api key from local file #116

ulf1 opened this issue Aug 24, 2018 · 1 comment

Comments

@ulf1
Copy link
Contributor

ulf1 commented Aug 24, 2018

Current Way

import quandl
quandl.ApiConfig.api_key = "mysecretkey"

Store a API Key

Save API Key string in a local text file, e.g. $HOME/.quandl_apikey

quandl.apikey_set("mysecretkey")

or a specified file, e.g.

quandl.apikey_set("mysecretkey", filepath="/data/.quandl_apikey")

Use cases

  • Users who don't want to expose their API key when sharing a Jupyter Notebook
  • Docker container with mount point /data/ to external storage (It's really painful to inject it with run command, and storing keys and tokens inside container is bad practice)

Implemention

https://github.com/ulf1/updoon/blob/master/updoon/quandl_apikey.py

this would read the file with the api like

import quandl
import updoon 
quandl.ApiConfig.api_key = updoon.quandl_apikey()

Proposal

Add save_key and read_key to api_config.py, e.g.

class ApiConfig:
     ....

def read_key(filepath=None):
    ...
    ApiConfig.api_key = ...

to do

import quandl
quandl.read_key()
...

instead of exposing the API key within a script.

@mbasset
Copy link
Contributor

mbasset commented Oct 2, 2018

Thanks @ulf1 ,

We have merged your changes into master. They will go out with our next release.

@mbasset mbasset closed this as completed Oct 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants