Skip to content

Commit

Permalink
Clarify token use with env variables and config files (cloudflare#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tugzrida authored and nijel committed Sep 20, 2019
1 parent c4f9107 commit 09d0605
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-...'
$
Expand All @@ -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 =
Expand Down
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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-...'
$
Expand All @@ -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 =
Expand Down

0 comments on commit 09d0605

Please sign in to comment.