Skip to content

Commit 849c87a

Browse files
committed
update examples
1 parent d6e383c commit 849c87a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

examples/examples/ex_authentication_demo.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,33 @@
1616
python ex_authentication_demo.py
1717
"""
1818

19+
import os
20+
from dotenv import load_dotenv
1921
from field_manager_python_client import authenticate, get_prod_client
2022
from field_manager_python_client.api.organizations import (
2123
get_organizations_organizations_get,
2224
)
2325

26+
# Load environment variables
27+
load_dotenv()
28+
DEFAULT_EMAIL = os.getenv("DEFAULT_EMAIL", "[email protected]")
29+
2430

2531
def main():
2632
"""Demonstrate different authentication methods."""
2733
print("🔐 Field Manager Authentication Examples")
2834
print()
2935

36+
# Use default email from environment
37+
email = DEFAULT_EMAIL
38+
print(f"Using email: {email}")
39+
print()
40+
3041
# Method 1: Manual authentication with environment selection
3142
print("Method 1: Manual authentication")
3243
try:
3344
# You can specify environment and email
34-
client = authenticate(environment="prod", email="your.email@example.com")
45+
client = authenticate(environment="prod", email=email)
3546

3647
# Test the client
3748
with client as client:
@@ -46,7 +57,7 @@ def main():
4657
print("Method 2: Using get_prod_client() helper function")
4758
try:
4859
# Simplified production client creation
49-
prod_client = get_prod_client(email="your.email@example.com")
60+
prod_client = get_prod_client(email=email)
5061

5162
# Test the client
5263
with prod_client as client:
@@ -66,10 +77,13 @@ def main():
6677
print("\nAdditional features:")
6778
print("- Automatic token caching and refresh")
6879
print("- Support for both SSO and password authentication")
69-
print("- No need for separate .env files")
80+
print("- Email loaded from .env file (DEFAULT_EMAIL)")
7081
print("- Built-in environment configurations")
7182
print("- Type hints and proper error handling")
7283

84+
print("\n💡 To use your own email, create a .env file with:")
85+
86+
7387

7488
if __name__ == "__main__":
7589
main()

examples/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
# Or run: python simple_setup.py
55
#
66
# For using the published version from PyPI (including pre-releases):
7-
field-manager-python-client>=4.6.25.post1
7+
field-manager-python-client>=4.6.25.post4
88

99
# For using the local development version (comment out the above line and uncomment below):
1010
# -e ../field-manager-python-client
1111

1212
# Authentication dependencies
13-
python-keycloak>=4.7.3
13+
python-keycloak>=5.5.0
1414

1515
# Data processing and visualization
1616
matplotlib>=3.10.0

0 commit comments

Comments
 (0)