Skip to content

Commit

Permalink
config file allows a per-method values
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Jan 18, 2020
1 parent 1a684ae commit 5f06e8a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,35 @@ def main():
...
```

### Advanced use of configuration file for authentication based on method

The configuration file can have values that are both generic and specific to the method.
Here's an example where a project has a different API Token for reading and writing values.

```bash
$ cat ~/.cloudflare/cloudflare.cfg
[Work]
token = 0000000000000000000000000000000000000000
token.get = 0123456789012345678901234567890123456789
$
```

When a GET call is processed then the second token is used. For all other calls the first token is used.
Here's a more explict verion of that config:

```bash
$ cat ~/.cloudflare/cloudflare.cfg
[Work]
token.delete = 0000000000000000000000000000000000000000
token.get = 0123456789012345678901234567890123456789
token.patch = 0000000000000000000000000000000000000000
token.post = 0000000000000000000000000000000000000000
token.put = 0000000000000000000000000000000000000000
$
```

This can be used with email values also.

### About /certificates and certtoken

The *CF_API_CERTKEY* or *certtoken* values are used for the Origin-CA */certificates* API calls.
Expand Down
32 changes: 32 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,38 @@ Here is the same in code.
cf = CloudFlare.CloudFlare(profile="Work")
...
Advanced use of configuration file for authentication based on method
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The configuration file can have values that are both generic and
specific to the method. Here's an example where a project has a
different API Token for reading and writing values.

.. code:: bash
$ cat ~/.cloudflare/cloudflare.cfg
[Work]
token = 0000000000000000000000000000000000000000
token.get = 0123456789012345678901234567890123456789
$
When a GET call is processed then the second token is used. For all
other calls the first token is used. Here's a more explict verion of
that config:

.. code:: bash
$ cat ~/.cloudflare/cloudflare.cfg
[Work]
token.delete = 0000000000000000000000000000000000000000
token.get = 0123456789012345678901234567890123456789
token.patch = 0000000000000000000000000000000000000000
token.post = 0000000000000000000000000000000000000000
token.put = 0000000000000000000000000000000000000000
$
This can be used with email values also.

About /certificates and certtoken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 5f06e8a

Please sign in to comment.