|
5 | 5 | ## ✨ Why Use This Client? |
6 | 6 |
|
7 | 7 | - **Easy Integration:** Each endpoint is ready to use—no manual HTTP calls needed. |
| 8 | +- **Seamless Authentication:** Built-in OAuth2/OIDC authentication with automatic token management. |
8 | 9 | - **Auto-Generated & Up-to-Date:** Always in sync with the latest Field Manager API updates. |
9 | 10 | - **Full Coverage:** Access every endpoint and model the Field Manager platform provides. |
10 | 11 |
|
11 | 12 | ## ⚙️ Installation & Setup |
12 | 13 |
|
13 | | -1. **Install** the package: |
| 14 | +1. **Install** the package with authentication support: |
14 | 15 |
|
15 | 16 | ```bash |
16 | | - pip install field-manager-python-client |
| 17 | + pip install field-manager-python-client python-keycloak |
17 | 18 | ``` |
18 | 19 |
|
19 | | -2. **Authenticate**: - Use the `authenticate` function to handle token retrieval automatically. This function will fetch a new token if the current one is expired or missing. |
| 20 | +2. **Authenticate**: Use the built-in authentication functions for seamless access: |
20 | 21 |
|
21 | 22 | ```python |
22 | | - from field_manager_python_client.api.projects import get_project_projects_project_id_get |
23 | | - from examples.setup_auto_fetch_token import authenticate |
| 23 | + from field_manager_python_client import get_prod_client |
24 | 24 |
|
25 | | - client = authenticate() # Handles token retrieval |
| 25 | + # Authenticate with your Field Manager account |
| 26 | + client = get_prod_client( email="[email protected]") |
26 | 27 | ``` |
27 | 28 |
|
28 | 29 | ## 🚀 Quick Example |
29 | 30 |
|
30 | | -1. Here's a [quick example](./examples/examples/ex_get_project_details.py) of how to fetch project information using the client: |
| 31 | +Here's how to fetch project information using the authenticated client: |
| 32 | + |
| 33 | +```python |
| 34 | +from field_manager_python_client import get_prod_client |
| 35 | +from field_manager_python_client.api.projects import get_project_projects_project_id_get |
| 36 | + |
| 37 | +# Authenticate and get client |
| 38 | +client = get_prod_client( email="[email protected]") |
| 39 | + |
| 40 | +# Use the client to fetch project data |
| 41 | +project_id = "your-project-id" |
| 42 | +project_info = get_project_projects_project_id_get.sync(client=client, project_id=project_id) |
| 43 | + |
| 44 | +print(f"Project Name: {project_info.name}") |
| 45 | +``` |
| 46 | + |
| 47 | +## 🔐 Authentication Options |
| 48 | + |
| 49 | +The client supports multiple authentication methods: |
| 50 | + |
| 51 | +1. **Integrated Authentication** (Recommended): |
31 | 52 |
|
32 | 53 | ```python |
33 | | - from field_manager_python_client.api.projects import get_project_projects_project_id_get |
34 | | - from examples.setup_auto_fetch_token import authenticate |
| 54 | + from field_manager_python_client import authenticate, get_prod_client |
| 55 | + |
| 56 | + client = authenticate( environment="prod", email="[email protected]") |
| 57 | + # or |
| 58 | + client = get_prod_client( email="[email protected]") |
| 59 | + ``` |
35 | 60 |
|
36 | | - client = authenticate() |
37 | | - project_id = "your-project-id" |
38 | | - project_info = get_project_projects_project_id_get.sync(client=client, project_id=project_id) |
| 61 | +2. **Manual Token Setup**: |
39 | 62 |
|
40 | | - print(f"Project Name: {project_info.name}") |
| 63 | + ```python |
| 64 | + from field_manager_python_client import AuthenticatedClient |
| 65 | + |
| 66 | + client = AuthenticatedClient( |
| 67 | + base_url="https://app.fieldmanager.io/api/location", |
| 68 | + token="your-access-token" |
| 69 | + ) |
41 | 70 | ``` |
42 | 71 |
|
| 72 | +3. **Service Account Authentication** (for automated workflows): |
| 73 | + - See the [Authentication Guide](./doc/AUTHENTICATION_GUIDE.md) for details |
| 74 | + - Also covered in the [Advanced User Guide](./doc/ADVANCED_USER_GUIDE.md) |
| 75 | + |
43 | 76 | ## 📂 Explore More Examples |
44 | 77 |
|
45 | | -- Check out the [examples folder](./examples/examples/) for scripts demonstrating how to: |
| 78 | +Check out the [examples folder](./examples/examples/) for scripts demonstrating how to: |
| 79 | + |
| 80 | +- **Authentication**: Multiple ways to authenticate with the API |
| 81 | +- **Organizations**: Fetch and manage organization data |
| 82 | +- **Projects**: Retrieve project details and metadata |
| 83 | +- **Locations**: Manage field locations and associated data |
| 84 | +- **Data Export**: Export project data in various formats |
| 85 | +- **Advanced Usage**: Async operations, bulk operations, and more |
| 86 | + |
| 87 | +## 📚 Documentation |
| 88 | + |
| 89 | +For comprehensive documentation, see the [`./doc/`](./doc/) directory: |
| 90 | + |
| 91 | +- **[Authentication Guide](./doc/AUTHENTICATION_GUIDE.md)**: Complete guide to all authentication methods |
| 92 | +- **[Advanced User Guide](./doc/ADVANCED_USER_GUIDE.md)**: In-depth coverage of sync/async operations and customizations |
| 93 | +- **[Examples Overview](./examples/EXAMPLES_OVERVIEW.md)**: Detailed overview of all available examples |
| 94 | + |
| 95 | +## 🏗️ For Developers |
46 | 96 |
|
47 | | - - Fetch organization(s) |
| 97 | +If you want to learn more about this library, contribute, or understand the internals, visit the main repository: [https://github.com/norwegian-geotechnical-institute/field-manager-python-client](https://github.com/norwegian-geotechnical-institute/field-manager-python-client) |
48 | 98 |
|
49 | | - - Manage locations |
| 99 | +The actual client package is auto-generated from the Field Manager API specification and includes: |
50 | 100 |
|
51 | | - - Compare data sets and more |
| 101 | +- Full type hints and IDE support |
| 102 | +- Comprehensive error handling |
| 103 | +- Both synchronous and asynchronous operations |
| 104 | +- Advanced customization options |
52 | 105 |
|
53 | 106 | ## 🤝 Contributing |
54 | 107 |
|
55 | | -We welcome issues, bug reports, and feature requests! |
| 108 | +We welcome issues, bug reports, and feature requests! Please check our [contributing guidelines](./doc/MAINTAINERS_GUIDE.md) and feel free to open an issue or submit a pull request. |
56 | 109 |
|
57 | 110 | --- |
58 | 111 |
|
|
0 commit comments