From 09d06054111cbc8f6454a3ae5568e240432dd22a Mon Sep 17 00:00:00 2001 From: Cameron Steel Date: Fri, 20 Sep 2019 19:03:08 +1000 Subject: [PATCH] Clarify token use with env variables and config files (#2) --- README.md | 6 ++++-- README.rst | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e8e4574..ba40207 100644 --- a/README.md +++ b/README.md @@ -198,11 +198,13 @@ import CloudFlare If the account email and API key are not passed when you create the class, then they are retrieved from either the users exported shell environment variables or the .cloudflare.cfg or ~/.cloudflare.cfg or ~/.cloudflare/cloudflare.cfg files, in that order. +If you're using an API Token, any `cloudflare.cfg` file must not contain an `email` attribute and the `CF_API_EMAIL` environment variable must be unset, otherwise the token will be treated as a key and will throw an error. + There is one call that presently doesn't need any email or token certification (the */ips* call); hence you can test without any values saved away. ### Using shell environment variables ```bash -$ export CF_API_EMAIL='user@example.com' +$ export CF_API_EMAIL='user@example.com' # Do not set if using an API Token $ export CF_API_KEY='00000000000000000000000000000000' $ export CF_API_CERTKEY='v1.0-...' $ @@ -215,7 +217,7 @@ These are optional environment variables; however, they do override the values s ```bash $ cat ~/.cloudflare/cloudflare.cfg [CloudFlare] -email = user@example.com +email = user@example.com # Do not set if using an API Token token = 00000000000000000000000000000000 certtoken = v1.0-... extras = diff --git a/README.rst b/README.rst index e97df98..fbcdc5a 100644 --- a/README.rst +++ b/README.rst @@ -225,6 +225,11 @@ class, then they are retrieved from either the users exported shell environment variables or the .cloudflare.cfg or ~/.cloudflare.cfg or ~/.cloudflare/cloudflare.cfg files, in that order. +If you're using an API Token, any ``cloudflare.cfg`` file must not +contain an ``email`` attribute and the ``CF_API_EMAIL`` environment +variable must be unset, otherwise the token will be treated as a key +and will throw an error. + There is one call that presently doesn't need any email or token certification (the */ips* call); hence you can test without any values saved away. @@ -234,7 +239,7 @@ Using shell environment variables .. code:: bash - $ export CF_API_EMAIL='user@example.com' + $ export CF_API_EMAIL='user@example.com' # Do not set if using an API Token $ export CF_API_KEY='00000000000000000000000000000000' $ export CF_API_CERTKEY='v1.0-...' $ @@ -249,7 +254,7 @@ Using configuration file to store email and keys $ cat ~/.cloudflare/cloudflare.cfg [CloudFlare] - email = user@example.com + email = user@example.com # Do not set if using an API Token token = 00000000000000000000000000000000 certtoken = v1.0-... extras =