webex-byova 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- webex_byova-0.1.0/.github/workflows/build-and-test.yml +50 -0
- webex_byova-0.1.0/.github/workflows/release.yml +31 -0
- webex_byova-0.1.0/.gitignore +19 -0
- webex_byova-0.1.0/CONTRIBUTING.md +56 -0
- webex_byova-0.1.0/LICENSE +21 -0
- webex_byova-0.1.0/PKG-INFO +113 -0
- webex_byova-0.1.0/README.md +78 -0
- webex_byova-0.1.0/docs/authentication.md +33 -0
- webex_byova-0.1.0/docs/automated-token-flow.md +37 -0
- webex_byova-0.1.0/docs/credentials.md +36 -0
- webex_byova-0.1.0/docs/data-sources.md +42 -0
- webex_byova-0.1.0/docs/getting-started.md +62 -0
- webex_byova-0.1.0/docs/index.md +19 -0
- webex_byova-0.1.0/docs/integration-oauth.md +45 -0
- webex_byova-0.1.0/docs/jws-verification.md +28 -0
- webex_byova-0.1.0/docs/mkdocs.yml +19 -0
- webex_byova-0.1.0/examples/quickstart_authorize.py +39 -0
- webex_byova-0.1.0/examples/quickstart_manual_token.py +22 -0
- webex_byova-0.1.0/examples/webhook_handler_fastapi.py +25 -0
- webex_byova-0.1.0/pyproject.toml +72 -0
- webex_byova-0.1.0/src/webex_byova/__init__.py +23 -0
- webex_byova-0.1.0/src/webex_byova/_http.py +122 -0
- webex_byova-0.1.0/src/webex_byova/_version.py +24 -0
- webex_byova-0.1.0/src/webex_byova/auth/__init__.py +17 -0
- webex_byova-0.1.0/src/webex_byova/auth/credentials.py +43 -0
- webex_byova-0.1.0/src/webex_byova/auth/integration.py +184 -0
- webex_byova-0.1.0/src/webex_byova/auth/redirect_listener.py +110 -0
- webex_byova-0.1.0/src/webex_byova/auth/service_app.py +127 -0
- webex_byova-0.1.0/src/webex_byova/auth/storage.py +50 -0
- webex_byova-0.1.0/src/webex_byova/auth/utils.py +22 -0
- webex_byova-0.1.0/src/webex_byova/client.py +142 -0
- webex_byova-0.1.0/src/webex_byova/config.py +24 -0
- webex_byova-0.1.0/src/webex_byova/exceptions.py +53 -0
- webex_byova-0.1.0/src/webex_byova/jws/__init__.py +5 -0
- webex_byova-0.1.0/src/webex_byova/jws/verifier.py +55 -0
- webex_byova-0.1.0/src/webex_byova/models/__init__.py +37 -0
- webex_byova-0.1.0/src/webex_byova/models/auth.py +56 -0
- webex_byova-0.1.0/src/webex_byova/models/datasource.py +70 -0
- webex_byova-0.1.0/src/webex_byova/models/schema.py +22 -0
- webex_byova-0.1.0/src/webex_byova/models/webhook.py +83 -0
- webex_byova-0.1.0/src/webex_byova/resources/__init__.py +6 -0
- webex_byova-0.1.0/src/webex_byova/resources/datasource.py +98 -0
- webex_byova-0.1.0/src/webex_byova/resources/schemas.py +33 -0
- webex_byova-0.1.0/src/webex_byova/webhooks/__init__.py +5 -0
- webex_byova-0.1.0/src/webex_byova/webhooks/manager.py +129 -0
- webex_byova-0.1.0/tests/conftest.py +53 -0
- webex_byova-0.1.0/tests/test_credentials.py +19 -0
- webex_byova-0.1.0/tests/test_datasource_crud.py +92 -0
- webex_byova-0.1.0/tests/test_integration_oauth.py +78 -0
- webex_byova-0.1.0/tests/test_jws_verifier.py +26 -0
- webex_byova-0.1.0/tests/test_service_app_tokens.py +64 -0
- webex_byova-0.1.0/tests/test_webhook_automation.py +235 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Build and Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
workflow_call:
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-and-test:
|
|
13
|
+
name: Build and Test
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
with:
|
|
22
|
+
fetch-depth: 0
|
|
23
|
+
fetch-tags: true
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: ${{ matrix.python-version }}
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: |
|
|
31
|
+
python -m pip install --upgrade pip
|
|
32
|
+
pip install -e ".[dev]"
|
|
33
|
+
pip install build
|
|
34
|
+
|
|
35
|
+
- name: Ruff
|
|
36
|
+
run: ruff check src tests
|
|
37
|
+
|
|
38
|
+
- name: Pytest
|
|
39
|
+
run: pytest tests/ -v
|
|
40
|
+
|
|
41
|
+
- name: Build
|
|
42
|
+
if: matrix.python-version == '3.12'
|
|
43
|
+
run: python -m build
|
|
44
|
+
|
|
45
|
+
- name: Upload Distribution Files
|
|
46
|
+
if: matrix.python-version == '3.12'
|
|
47
|
+
uses: actions/upload-artifact@v4
|
|
48
|
+
with:
|
|
49
|
+
name: distribution-files
|
|
50
|
+
path: dist/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-test:
|
|
10
|
+
name: Build and Test
|
|
11
|
+
uses: ./.github/workflows/build-and-test.yml
|
|
12
|
+
secrets: inherit
|
|
13
|
+
|
|
14
|
+
pypi:
|
|
15
|
+
needs: build-and-test
|
|
16
|
+
name: Publish to PyPI
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
environment: pypi.org
|
|
19
|
+
permissions:
|
|
20
|
+
id-token: write
|
|
21
|
+
steps:
|
|
22
|
+
- name: Download Distribution Files
|
|
23
|
+
uses: actions/download-artifact@v4
|
|
24
|
+
with:
|
|
25
|
+
name: distribution-files
|
|
26
|
+
path: dist/
|
|
27
|
+
- name: Publish to PyPI
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
29
|
+
with:
|
|
30
|
+
repository-url: ${{ vars.PYPI_REPOSITORY_URL }}
|
|
31
|
+
print-hash: true
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Contributing to webex-byova
|
|
2
|
+
|
|
3
|
+
Thank you for contributing to the Webex BYOVA Python SDK.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone <your-fork>
|
|
9
|
+
cd BYOVA_SDK_STARTER
|
|
10
|
+
python3 -m venv .venv
|
|
11
|
+
source .venv/bin/activate
|
|
12
|
+
pip install -e ".[dev]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Running tests
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pytest tests/ -v
|
|
19
|
+
ruff check src tests
|
|
20
|
+
ruff format src tests
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Pull request process
|
|
24
|
+
|
|
25
|
+
1. Fork the repository and create a feature branch.
|
|
26
|
+
2. Add tests for new behavior.
|
|
27
|
+
3. Ensure `pytest` and `ruff check` pass.
|
|
28
|
+
4. Update documentation under `docs/` for user-facing changes.
|
|
29
|
+
5. Open a pull request with a clear description and test plan.
|
|
30
|
+
|
|
31
|
+
## Release process (maintainers)
|
|
32
|
+
|
|
33
|
+
1. Merge changes to `main`.
|
|
34
|
+
2. Create and push a version tag (version is derived from the tag via hatch-vcs):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git tag v0.x.x
|
|
38
|
+
git push origin v0.x.x
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. GitHub Actions runs tests, builds the package, and publishes to PyPI via trusted publishing.
|
|
42
|
+
|
|
43
|
+
### One-time PyPI setup
|
|
44
|
+
|
|
45
|
+
- Create a GitHub environment named `pypi.org`.
|
|
46
|
+
- Configure [PyPI trusted publishing](https://docs.pypi.org/trusted-publishers/) for this repository:
|
|
47
|
+
- Workflow: `release.yml`
|
|
48
|
+
- Environment: `pypi.org`
|
|
49
|
+
- Optionally set repository variable `PYPI_REPOSITORY_URL` to `https://test.pypi.org/legacy/` for TestPyPI dry runs.
|
|
50
|
+
|
|
51
|
+
## Code style
|
|
52
|
+
|
|
53
|
+
- Python 3.10+
|
|
54
|
+
- Type hints encouraged
|
|
55
|
+
- Keep public API documented with docstrings
|
|
56
|
+
- Match existing patterns in `src/webex_byova/`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Webex BYOVA SDK Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: webex-byova
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Webex Contact Center BYOVA / BYODS — Data Sources, Service App tokens, and Integration OAuth
|
|
5
|
+
Project-URL: Homepage, https://github.com/Joezanini/byova-sdk-python
|
|
6
|
+
Project-URL: Documentation, https://github.com/Joezanini/byova-sdk-python#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/Joezanini/byova-sdk-python
|
|
8
|
+
Author: Webex BYOVA SDK Contributors
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: byods,byova,contact-center,virtual-agent,webex
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: httpx>=0.27.0
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
Requires-Dist: pyjwt[crypto]>=2.8.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
30
|
+
Provides-Extra: docs
|
|
31
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
32
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
33
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == 'docs'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# webex-byova
|
|
37
|
+
|
|
38
|
+
Python SDK for **Webex Contact Center BYOVA** and the foundational **Bring Your Own Data Source (BYODS)** APIs.
|
|
39
|
+
|
|
40
|
+
Simplify Service App token management, Integration OAuth, DataSource CRUD, schema discovery, and JWS verification.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install webex-byova
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import asyncio
|
|
52
|
+
from webex_byova import BYOVA
|
|
53
|
+
from webex_byova.models import IntegrationCredentials, ServiceAppCredentials
|
|
54
|
+
|
|
55
|
+
sdk = BYOVA(
|
|
56
|
+
integration=IntegrationCredentials(
|
|
57
|
+
client_id="YOUR_INTEGRATION_CLIENT_ID",
|
|
58
|
+
client_secret="YOUR_INTEGRATION_CLIENT_SECRET",
|
|
59
|
+
redirect_uri="http://127.0.0.1:8765/callback",
|
|
60
|
+
),
|
|
61
|
+
service_app=ServiceAppCredentials(
|
|
62
|
+
client_id="YOUR_SERVICE_APP_CLIENT_ID",
|
|
63
|
+
client_secret="YOUR_SERVICE_APP_CLIENT_SECRET",
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
async def main():
|
|
68
|
+
# Developer authorizes Integration (not customer admin)
|
|
69
|
+
await sdk.integration.aauthorize(
|
|
70
|
+
scopes=[
|
|
71
|
+
"spark:applications_token",
|
|
72
|
+
"application:webhooks_write",
|
|
73
|
+
"application:webhooks_read",
|
|
74
|
+
],
|
|
75
|
+
open_browser=True,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
await sdk.webhooks.aensure_service_app_webhooks(
|
|
79
|
+
target_url="https://your-app.example.com/webhooks/webex",
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
asyncio.run(main())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
After a customer admin authorizes your Service App in Control Hub, handle the webhook:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
result = await sdk.ahandle_service_app_webhook(webhook_json)
|
|
89
|
+
client = await sdk.aget_client_for_org(result.org_id)
|
|
90
|
+
sources = await client.data_sources.alist()
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Environment variables
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
export WEBEX_INTEGRATION_CLIENT_ID=...
|
|
97
|
+
export WEBEX_INTEGRATION_CLIENT_SECRET=...
|
|
98
|
+
export WEBEX_SA_CLIENT_ID=...
|
|
99
|
+
export WEBEX_SA_CLIENT_SECRET=...
|
|
100
|
+
export WEBEX_INTEGRATION_REDIRECT_URI=http://127.0.0.1:8765/callback
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
sdk = BYOVA.from_env()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Documentation
|
|
108
|
+
|
|
109
|
+
See the [docs/](docs/) directory and [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# webex-byova
|
|
2
|
+
|
|
3
|
+
Python SDK for **Webex Contact Center BYOVA** and the foundational **Bring Your Own Data Source (BYODS)** APIs.
|
|
4
|
+
|
|
5
|
+
Simplify Service App token management, Integration OAuth, DataSource CRUD, schema discovery, and JWS verification.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install webex-byova
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import asyncio
|
|
17
|
+
from webex_byova import BYOVA
|
|
18
|
+
from webex_byova.models import IntegrationCredentials, ServiceAppCredentials
|
|
19
|
+
|
|
20
|
+
sdk = BYOVA(
|
|
21
|
+
integration=IntegrationCredentials(
|
|
22
|
+
client_id="YOUR_INTEGRATION_CLIENT_ID",
|
|
23
|
+
client_secret="YOUR_INTEGRATION_CLIENT_SECRET",
|
|
24
|
+
redirect_uri="http://127.0.0.1:8765/callback",
|
|
25
|
+
),
|
|
26
|
+
service_app=ServiceAppCredentials(
|
|
27
|
+
client_id="YOUR_SERVICE_APP_CLIENT_ID",
|
|
28
|
+
client_secret="YOUR_SERVICE_APP_CLIENT_SECRET",
|
|
29
|
+
),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
async def main():
|
|
33
|
+
# Developer authorizes Integration (not customer admin)
|
|
34
|
+
await sdk.integration.aauthorize(
|
|
35
|
+
scopes=[
|
|
36
|
+
"spark:applications_token",
|
|
37
|
+
"application:webhooks_write",
|
|
38
|
+
"application:webhooks_read",
|
|
39
|
+
],
|
|
40
|
+
open_browser=True,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
await sdk.webhooks.aensure_service_app_webhooks(
|
|
44
|
+
target_url="https://your-app.example.com/webhooks/webex",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
asyncio.run(main())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
After a customer admin authorizes your Service App in Control Hub, handle the webhook:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
result = await sdk.ahandle_service_app_webhook(webhook_json)
|
|
54
|
+
client = await sdk.aget_client_for_org(result.org_id)
|
|
55
|
+
sources = await client.data_sources.alist()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Environment variables
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
export WEBEX_INTEGRATION_CLIENT_ID=...
|
|
62
|
+
export WEBEX_INTEGRATION_CLIENT_SECRET=...
|
|
63
|
+
export WEBEX_SA_CLIENT_ID=...
|
|
64
|
+
export WEBEX_SA_CLIENT_SECRET=...
|
|
65
|
+
export WEBEX_INTEGRATION_REDIRECT_URI=http://127.0.0.1:8765/callback
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
sdk = BYOVA.from_env()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Documentation
|
|
73
|
+
|
|
74
|
+
See the [docs/](docs/) directory and [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Authentication
|
|
2
|
+
|
|
3
|
+
## Responsibilities
|
|
4
|
+
|
|
5
|
+
| Actor | Action |
|
|
6
|
+
|-------|--------|
|
|
7
|
+
| Developer | Authorize Integration via SDK |
|
|
8
|
+
| Developer | Register webhooks, host HTTPS endpoint |
|
|
9
|
+
| Customer admin | Authorize Service App in Control Hub |
|
|
10
|
+
| SDK | Fetch/store per-org Service App tokens |
|
|
11
|
+
|
|
12
|
+
## Token storage
|
|
13
|
+
|
|
14
|
+
Implement `TokenStorage` for production (Redis, database, secrets manager):
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from webex_byova.auth import TokenStorage
|
|
18
|
+
|
|
19
|
+
class RedisTokenStorage:
|
|
20
|
+
async def get_integration_tokens(self): ...
|
|
21
|
+
async def set_integration_tokens(self, tokens): ...
|
|
22
|
+
# ...
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Default: `InMemoryTokenStorage` (development only).
|
|
26
|
+
|
|
27
|
+
## Paths to Service App tokens
|
|
28
|
+
|
|
29
|
+
**Webhook (production):** `handle_service_app_webhook` after customer admin authorizes.
|
|
30
|
+
|
|
31
|
+
**Manual (sandbox):** `await sdk.service_app.asave_registration(org_id, refresh_token)`
|
|
32
|
+
|
|
33
|
+
**On-demand:** `await sdk.service_app.afetch_token_for_org(org_id)` when org is already authorized.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Automated Token Flow
|
|
2
|
+
|
|
3
|
+
End-to-end flow for multi-tenant BYOVA apps.
|
|
4
|
+
|
|
5
|
+
```mermaid
|
|
6
|
+
sequenceDiagram
|
|
7
|
+
participant Dev as Developer
|
|
8
|
+
participant SDK as webex_byova
|
|
9
|
+
participant WX as Webex
|
|
10
|
+
participant Admin as CustomerAdmin
|
|
11
|
+
|
|
12
|
+
Dev->>SDK: integration.authorize()
|
|
13
|
+
Dev->>SDK: webhooks.ensure_service_app_webhooks(url)
|
|
14
|
+
Admin->>WX: Authorize Service App in Control Hub
|
|
15
|
+
WX->>Dev: POST webhook authorized
|
|
16
|
+
Dev->>SDK: handle_service_app_webhook(payload)
|
|
17
|
+
SDK->>WX: POST /applications/{id}/token
|
|
18
|
+
Dev->>SDK: get_client_for_org(org_id)
|
|
19
|
+
Dev->>SDK: data_sources.create(...)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Steps
|
|
23
|
+
|
|
24
|
+
1. **Developer** runs `integration.authorize()` (Integration OAuth).
|
|
25
|
+
2. **Developer** calls `webhooks.ensure_service_app_webhooks(target_url)`.
|
|
26
|
+
3. **Customer admin** authorizes the Service App in Control Hub.
|
|
27
|
+
4. **Your HTTPS endpoint** receives `serviceApp` / `authorized` webhook.
|
|
28
|
+
5. Call `sdk.ahandle_service_app_webhook(payload)` — SDK fetches and stores org tokens.
|
|
29
|
+
6. Use `aget_client_for_org(org_id)` for DataSource CRUD.
|
|
30
|
+
|
|
31
|
+
## Deauthorization
|
|
32
|
+
|
|
33
|
+
On `deauthorized`, `handle_service_app_webhook` removes stored tokens for that org.
|
|
34
|
+
|
|
35
|
+
## Service App events use webhooks (not Mercury)
|
|
36
|
+
|
|
37
|
+
Unlike [webex_bot](https://github.com/fbradyirl/webex_bot) messaging bots, Service App lifecycle events are delivered via **HTTPS webhooks only**, not Webex Mercury WebSockets.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Credentials
|
|
2
|
+
|
|
3
|
+
The SDK uses a **two-tier credential model**. You supply all OAuth client credentials from the Webex Developer Portal.
|
|
4
|
+
|
|
5
|
+
## Integration (developer-owned)
|
|
6
|
+
|
|
7
|
+
| Field | Description |
|
|
8
|
+
|-------|-------------|
|
|
9
|
+
| `client_id` | Integration Client ID |
|
|
10
|
+
| `client_secret` | Integration Client Secret |
|
|
11
|
+
| `redirect_uri` | Must match a redirect URI on the Integration |
|
|
12
|
+
|
|
13
|
+
Used for: Integration OAuth, webhook registration, fetching Service App tokens per org.
|
|
14
|
+
|
|
15
|
+
**Who authorizes:** The developer who owns the Integration — via `integration.authorize()`.
|
|
16
|
+
|
|
17
|
+
## Service App (per customer org)
|
|
18
|
+
|
|
19
|
+
| Field | Description |
|
|
20
|
+
|-------|-------------|
|
|
21
|
+
| `client_id` | Service App Client ID |
|
|
22
|
+
| `client_secret` | Service App Client Secret |
|
|
23
|
+
|
|
24
|
+
Used for: Request body when calling `POST /applications/{id}/token`; Bearer token on DataSource API calls.
|
|
25
|
+
|
|
26
|
+
**Who authorizes:** Each customer's Full Admin in Control Hub — not via SDK OAuth.
|
|
27
|
+
|
|
28
|
+
## Environment variables
|
|
29
|
+
|
|
30
|
+
| Variable | Purpose |
|
|
31
|
+
|----------|---------|
|
|
32
|
+
| `WEBEX_INTEGRATION_CLIENT_ID` | Integration client ID |
|
|
33
|
+
| `WEBEX_INTEGRATION_CLIENT_SECRET` | Integration client secret |
|
|
34
|
+
| `WEBEX_INTEGRATION_REDIRECT_URI` | OAuth redirect (default `http://127.0.0.1:8765/callback`) |
|
|
35
|
+
| `WEBEX_SA_CLIENT_ID` | Service App client ID |
|
|
36
|
+
| `WEBEX_SA_CLIENT_SECRET` | Service App client secret |
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Data Sources
|
|
2
|
+
|
|
3
|
+
## CRUD operations
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
client = await sdk.aget_client_for_org(org_id)
|
|
7
|
+
|
|
8
|
+
# List
|
|
9
|
+
items = await client.data_sources.alist()
|
|
10
|
+
|
|
11
|
+
# Create
|
|
12
|
+
from webex_byova.models import DataSourceCreate
|
|
13
|
+
ds = await client.data_sources.acreate(DataSourceCreate(
|
|
14
|
+
audience="MyApp",
|
|
15
|
+
subject="callAudioData",
|
|
16
|
+
nonce="unique-nonce",
|
|
17
|
+
schema_id="78efc775-dccb-45ca-9acf-989a4a59f788",
|
|
18
|
+
url="https://dap.example.com/ingest",
|
|
19
|
+
token_lifetime_minutes=60,
|
|
20
|
+
))
|
|
21
|
+
|
|
22
|
+
# Get / Update / Delete
|
|
23
|
+
detail = await client.data_sources.aget(ds.id)
|
|
24
|
+
await client.data_sources.aupdate(ds.id, {"status": "disabled", "errorMessage": "maintenance"})
|
|
25
|
+
await client.data_sources.adelete(ds.id)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Schemas
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
schemas = await client.schemas.alist()
|
|
32
|
+
schema = await client.schemas.aget(schema_id)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Token extension
|
|
36
|
+
|
|
37
|
+
Update with a new `nonce` and `tokenLifetimeMinutes` before the JWS token expires (max 1440 minutes).
|
|
38
|
+
|
|
39
|
+
## Scopes
|
|
40
|
+
|
|
41
|
+
- Read: `spark-admin:datasource_read`
|
|
42
|
+
- Write: `spark-admin:datasource_write`
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
1. A [Webex Developer](https://developer.webex.com/) account
|
|
6
|
+
2. A **Webex Integration** with scopes:
|
|
7
|
+
- `spark:applications_token`
|
|
8
|
+
- `application:webhooks_write`
|
|
9
|
+
- `application:webhooks_read`
|
|
10
|
+
3. A **Webex Service App** with BYODS scopes:
|
|
11
|
+
- `spark-admin:datasource_read`
|
|
12
|
+
- `spark-admin:datasource_write`
|
|
13
|
+
4. Redirect URI registered on the Integration (e.g. `http://127.0.0.1:8765/callback`)
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install webex-byova
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Authorize Integration and register webhooks
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import asyncio
|
|
25
|
+
from webex_byova import BYOVA
|
|
26
|
+
from webex_byova.models import IntegrationCredentials, ServiceAppCredentials
|
|
27
|
+
|
|
28
|
+
sdk = BYOVA(
|
|
29
|
+
integration=IntegrationCredentials(...),
|
|
30
|
+
service_app=ServiceAppCredentials(...),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
async def setup():
|
|
34
|
+
await sdk.integration.aauthorize(
|
|
35
|
+
scopes=[
|
|
36
|
+
"spark:applications_token",
|
|
37
|
+
"application:webhooks_write",
|
|
38
|
+
"application:webhooks_read",
|
|
39
|
+
],
|
|
40
|
+
)
|
|
41
|
+
await sdk.webhooks.aensure_service_app_webhooks(
|
|
42
|
+
"https://your-server.example.com/webhooks/webex"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
asyncio.run(setup())
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Register a data source
|
|
49
|
+
|
|
50
|
+
After a customer admin authorizes your Service App, handle the `authorized` webhook, then:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
client = await sdk.aget_client_for_org(org_id)
|
|
54
|
+
await client.data_sources.acreate({
|
|
55
|
+
"audience": "MyVirtualAgent",
|
|
56
|
+
"subject": "callAudioData",
|
|
57
|
+
"nonce": "unique-nonce-string",
|
|
58
|
+
"schemaId": "<schema-uuid>",
|
|
59
|
+
"url": "https://your-dap.example.com/ingest",
|
|
60
|
+
"tokenLifetimeMinutes": 60,
|
|
61
|
+
})
|
|
62
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# webex-byova
|
|
2
|
+
|
|
3
|
+
Python SDK for Webex Contact Center **Bring Your Own Virtual Agent (BYOVA)** and **Bring Your Own Data Source (BYODS)**.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Integration OAuth** with built-in redirect listener (`integration.authorize()`)
|
|
8
|
+
- **Service App tokens** per organization (webhook-driven or manual)
|
|
9
|
+
- **DataSource CRUD** — register, list, update, delete data sources
|
|
10
|
+
- **Schema discovery** — list and inspect BYODS schemas
|
|
11
|
+
- **JWS verification** — validate inbound tokens from Webex
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install webex-byova
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
See [Getting Started](getting-started.md) for the full walkthrough.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Integration OAuth
|
|
2
|
+
|
|
3
|
+
The developer authorizes the **Integration** on their own behalf. The SDK provides a built-in redirect listener — no separate OAuth server required for local development.
|
|
4
|
+
|
|
5
|
+
## Primary flow: `authorize()`
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
tokens = await sdk.integration.aauthorize(
|
|
9
|
+
scopes=[
|
|
10
|
+
"spark:applications_token",
|
|
11
|
+
"application:webhooks_write",
|
|
12
|
+
"application:webhooks_read",
|
|
13
|
+
],
|
|
14
|
+
open_browser=True,
|
|
15
|
+
timeout=300,
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will:
|
|
20
|
+
|
|
21
|
+
1. Build the authorization URL
|
|
22
|
+
2. Start a temporary HTTP server on `redirect_uri`
|
|
23
|
+
3. Open the system browser (optional)
|
|
24
|
+
4. Capture `?code=` from the redirect
|
|
25
|
+
5. Exchange the code and store tokens
|
|
26
|
+
|
|
27
|
+
## Manual / CI flow
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
url, state = sdk.integration.get_authorization_url(scopes=[...])
|
|
31
|
+
# Complete OAuth in browser, then:
|
|
32
|
+
tokens = await sdk.integration.aexchange_code(code)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Redirect URI requirements
|
|
36
|
+
|
|
37
|
+
- Must be registered on your Integration in the Developer Portal
|
|
38
|
+
- `http://127.0.0.1:8765/callback` works for local development
|
|
39
|
+
- Production integrations may use HTTPS callbacks on your own server; use `exchange_code()` if you handle the redirect externally
|
|
40
|
+
|
|
41
|
+
## Token refresh
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
token = await sdk.integration.aget_access_token() # auto-refreshes if expired
|
|
45
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# JWS Verification
|
|
2
|
+
|
|
3
|
+
When Webex sends data to your DAP endpoint, it includes a JWS token in the request header. Verify it before processing:
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
claims = sdk.verify_jws_token(jws_token)
|
|
7
|
+
# or async:
|
|
8
|
+
claims = await sdk.averify_jws_token(jws_token)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Regions
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from webex_byova import BYOVAConfig
|
|
15
|
+
|
|
16
|
+
config = BYOVAConfig(region="eu") # uses EU JWK endpoint
|
|
17
|
+
sdk = BYOVA(..., config=config)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
US JWK: `https://idbroker.webex.com/idb/oauth2/v2/keys/verificationjwk`
|
|
21
|
+
|
|
22
|
+
EU JWK: `https://idbroker-eu.webex.com/idb/oauth2/v2/keys/verificationjwk`
|
|
23
|
+
|
|
24
|
+
## Security
|
|
25
|
+
|
|
26
|
+
- Rotate `nonce` regularly on data source updates
|
|
27
|
+
- Refresh tokens before `tokenLifetimeMinutes` expires
|
|
28
|
+
- Never log full JWS tokens in production
|