Skip to content

Commit

Permalink
Merge pull request #10 from corbado/feature/openapi-v2
Browse files Browse the repository at this point in the history
Feature/openapi v2
  • Loading branch information
alexbalakirev authored Aug 30, 2024
2 parents 716299b + 9e94a59 commit 20cee2f
Show file tree
Hide file tree
Showing 343 changed files with 13,093 additions and 40,781 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
#TODO: move lint to separate job
#TODO: coverage tests in separate job
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions. It also publishes to pypi.org on version tags.

name: Python package

Expand Down Expand Up @@ -41,6 +38,7 @@ jobs:
# Linting step only runs for Python 3.8
- name: mypy
if: matrix.python-version == '3.8'
continue-on-error: true
run: mypy -p corbado_python_sdk --exclude generated --strict --disable-error-code attr-defined
- name: lint with flake8
if: matrix.python-version == '3.8'
Expand All @@ -50,7 +48,7 @@ jobs:
run: |
tox run
env:
CORBADO_BACKEND_API: ${{ secrets.CORBADO_BACKEND_API }}
CORBADO_BACKEND_API: ${{ vars.CORBADO_BACKEND_API }}
CORBADO_API_SECRET: ${{ secrets.CORBADO_API_SECRET }}
CORBADO_PROJECT_ID: ${{ secrets.CORBADO_PROJECT_ID }}

Expand Down Expand Up @@ -87,7 +85,7 @@ jobs:
name: >-
Publish Python distribution package to PyPI
if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on tag pushes
needs: [build,test-and-lint] # Ensure that package was built and tested for all python versions before publishing
needs: [build,test-and-lint] # Ensure that package was built and tested for all python versions before publishing
runs-on: ubuntu-latest
environment:
name: pypi
Expand Down
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,35 @@ A list of examples can be found in the integration tests [here](tests/integratio

The Corbado Python SDK provides the following services:

- `auth_tokens` for managing authentication tokens needed for own session management ([examples](tests/integration/test_auth_token_service.py))
- `email_magic_links` for managing email magic links ([examples](tests/integration/test_email_magic_link_service.py))
- `email_otps` for managing email OTPs ([examples](tests/integration/test_email_otp_service.py))
- `sessions` for managing sessions ([example flask app](tests/utils/session_service_example.py))
- `sms_otps` for managing SMS OTPs ([examples](tests/integration/test_sms_otp_service.py))
- `users` for managing users ([examples](tests/integration/test_user_service.py))
- `validations` for validating email addresses and phone numbers ([examples](tests/integration/test_validation_service.py))
- `sessions` for managing sessions ([example flask app](https://github.com/corbado/example-passkeys-python-flask))
- `users` for managing users ([examples](tests/integration/test_identifier_service.py))
- `identifiers` for managing login identifiers ([examples](tests/integration/test_user_service.py))

To use a specific service, such as `users`, invoke it as shown below:

```Python
user_service: UserInterface = sdk.users
user_service: UserService = sdk.users
```

## :books: Advanced

### Error handling

The Corbado Python SDK throws exceptions for all errors. The following exceptions are thrown:
The Corbado Python SDK raises exceptions for all errors except those that occur in the session service during token validation (See example below on how to catch those errors). The following exceptions are thrown:

- `ValidationError` for failed validations (client side)
- `ServerException` for server errors (server side)
- `StandardException` for everything else (client side)

'SessionService' returns 'SessionValidationResult' as result of token validation. You can check whether any errors occurred and handle them if needed:

```Python
result: SessionValidationResult = self.session_service.get_and_validate_short_session_value(short_session=token)
if result.error is not None:
print(result.error)
raise result.error
```

If the Backend API returns a HTTP status code other than 200, the Corbado Python SDK throws a `ServerException`. The `ServerException`class provides convenient methods to access all important data:
sdk.users.get(user_id="usr-123456789")

Expand Down Expand Up @@ -109,7 +114,7 @@ Add environment variables for tests (use the test project from secrets repositot
``` console
export CORBADO_API_SECRET=corbado1_123456
export CORBADO_PROJECT_ID=pro-123456
export CORBADO_BACKEND_API=https://backendapi.corbado.io
export CORBADO_BACKEND_API="https://backendapi.cloud.corbado.io"
```

# Testing
Expand Down Expand Up @@ -148,7 +153,7 @@ If you encounter any bugs or have suggestions, please [open an issue](https://gi

Join our Slack channel to discuss questions or ideas with the Corbado team and other developers.

[![Slack](https://img.shields.io/badge/slack-join%20chat-brightgreen.svg)](https://join.slack.com/t/corbado/shared_invite/zt-1b7867yz8-V~Xr~ngmSGbt7IA~g16ZsQ)
[![Slack](https://img.shields.io/badge/slack-join%20chat-brightgreen.svg)](https://bit.ly/passkeys-community)

### Email

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.1.2
Empty file removed examples/__init__.py
Empty file.
Empty file removed scripts/__init__.py
Empty file.
Loading

0 comments on commit 20cee2f

Please sign in to comment.