1
0
mirror of synced 2026-01-20 21:06:36 -05:00
Files
airbyte/airbyte-integrations/connectors/source-auth0/source_auth0/authenticator.py
Yiyang Li 4fdd09b79c 🎉 New Source: Auth0 [python cdk] (#18338)
* 🎉 New Source: Auth0 [python cdk]

- Full import and incremental are supported
- Only users stream is added
- Added unit tests and ensure all acceptance tests are passed locally
- It's free to create a new account in Auth0, so it's free to setup an integration account.

* fix: remove unused import in source.py

* auto-bump connector version

Co-authored-by: sajarin <sajarindider@gmail.com>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
2022-10-26 13:55:16 -04:00

29 lines
967 B
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
import logging
from typing import Any, Mapping
from urllib import parse
from airbyte_cdk.sources.streams.http.requests_native_auth import Oauth2Authenticator
logger = logging.getLogger("airbyte")
class Auth0Oauth2Authenticator(Oauth2Authenticator):
def __init__(self, base_url: str, audience: str, client_id: str, client_secret: str):
super().__init__(parse.urljoin(base_url, "/oauth/token"), client_id, client_secret, "")
self.audience = audience.rstrip("/") + "/"
def build_refresh_request_body(self) -> Mapping[str, Any]:
if not self.get_refresh_token():
return {
"grant_type": "client_credentials",
"client_id": self.get_client_id(),
"client_secret": self.get_client_secret(),
"audience": self.audience,
}
else:
return super().build_refresh_request_body()