Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rest_api: Add OAuth2ClientCredentials to the list of built-in auth methods #1870

Closed
5 tasks done
willi-mueller opened this issue Aug 14, 2024 · 0 comments · Fixed by #1871
Closed
5 tasks done

rest_api: Add OAuth2ClientCredentials to the list of built-in auth methods #1870

willi-mueller opened this issue Aug 14, 2024 · 0 comments · Fixed by #1871
Assignees

Comments

@willi-mueller
Copy link
Collaborator

willi-mueller commented Aug 14, 2024

rest_Add OAuth2ClientCredentials to the current list of built-in auth methods.

This requires changes only in the dlt-core repo in rest_client/auth.py

Tasks:

  • in sources/rest_api/typing.py: add AuthType, add OAuth2Config
  • remove __init()__
  • implement __post_init__()
  • uncomment skip in tests/rest_api/test_configurations.py::test_auth_type_configs
  • update docs

Specification:

The code should look like as follows:

@configspec
class OAuth2ClientCredentials(OAuth2AuthBase):
    """
    This class implements OAuth2 Client Credentials flow where the autorization service
    gives permission without the end user approving.
    This is often used for machine-to-machine authorization.
    The client sends its client ID and client secret to the authorization service which replies
    with a temporary access token.
    With the access token, the client can access resource services.
    """
    access_token_url: TSecretStrValue = None
    client_id: TSecretStrValue = None
    client_secret: TSecretStrValue = None
    access_token_request_data: Dict[str, Any] = None
    default_token_expiration: int = 3600
    session: Annotated[BaseSession, NotResolved()] = None

    def __post_init__(self) -> None:
        if self.access_token_request_data is None:
            self.access_token_request_data = {}

        self.token_expiry: pendulum.DateTime = pendulum.now()

        if self.session is None:
            self.session = requests.client.session
@willi-mueller willi-mueller changed the title Add OAuth2ClientCredentials to the current list of built-in auth methods rest_api: Add OAuth2ClientCredentials to the list of built-in auth methods Aug 14, 2024
@willi-mueller willi-mueller self-assigned this Aug 14, 2024
@burnash burnash transferred this issue from dlt-hub/verified-sources Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for Deployment
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant