You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,45 @@ The REST API documentation can be found on [developers.cloudflare.com](https://d
29
29
pip install --pre cloudflare
30
30
```
31
31
32
+
## Authentication
33
+
34
+
The SDK supports multiple authentication methods. Each can be provided as a constructor argument or read automatically from an environment variable.
35
+
36
+
### API Token (recommended)
37
+
38
+
[API tokens](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) are scoped to specific permissions and are the recommended way to authenticate.
39
+
40
+
```python
41
+
from cloudflare import Cloudflare
42
+
43
+
client = Cloudflare(api_token="your-api-token")
44
+
45
+
# Or set the CLOUDFLARE_API_TOKEN environment variable and omit the argument:
46
+
client = Cloudflare()
47
+
```
48
+
49
+
### API Key + Email
50
+
51
+
The [Global API Key](https://developers.cloudflare.com/fundamentals/api/get-started/keys/) authenticates using a key and email pair. Both must be provided together.
52
+
53
+
```python
54
+
from cloudflare import Cloudflare
55
+
56
+
client = Cloudflare(
57
+
api_key="your-global-api-key",
58
+
api_email="user@example.com",
59
+
)
60
+
61
+
# Or set CLOUDFLARE_API_KEY and CLOUDFLARE_EMAIL environment variables:
62
+
client = Cloudflare()
63
+
```
64
+
65
+
| Parameter | Environment variable | Header sent |
0 commit comments