Hi! I have a question about the authentication via...
# help-api-cli-orchestration
c
Hi! I have a question about the authentication via Python to a local OSS instance, in order to automate the creation of sources/destinations/connections? I found the pip package "airbyte-api-python-sdk" and in the documentation in every example uses for the authentication
Copy code
s = airbyte.Airbyte(
    security=shared.Security(
        bearer_auth="",
    ),
)
without any explanation about whats happening there. Is there a way to change that to basic auth or something so i can test locally if that script would work in production? Or where can I find documentation about how to properly use that?
u
Based on the information provided in the extracts, it seems that the Airbyte Python CDK supports Basic and OAuth2.0 authentication via the
TokenAuthenticator
and
Oauth2Authenticator
classes respectively. Both authentication strategies place the API token in the
Authorization
header. The
OAuth2Authenticator
goes a step further and has mechanisms to refresh the current access token given a refresh token. However, it currently only supports refresh tokens and not the full OAuth2.0 loop. You can use either authenticator by passing the created authenticator into the relevant
HTTPStream
constructor. Here is an [example](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-stripe/source_stripe/source.py#L242) from the Stripe API [source](https://docs.airbyte.com/connector-development/cdk-python/http-streams). For complex custom authentication schemes involving signing requests or doing multiple requests to authenticate, you can use the [low-code CDK](https://docs.airbyte.com/connector-development/config-based/low-code-cdk-overview) or [Python CDK](https://docs.airbyte.com/connector-development/cdk-python/) [source](https://docs.airbyte.com/connector-development/connector-builder-ui/authentication). However, the specific package "airbyte-api-python-sdk" and its usage are not mentioned in the provided extracts. For more detailed information on how to use this package, I would recommend checking the official documentation or reaching out to the Airbyte community on [Slack](https://slack.airbyte.io) or their [forum](https://discuss.airbyte.io).
c
@kapa.ai If I try to implement the OAuth2Authenticator by using the following Code
s = airbyte.Airbyte(
security=  Oauth2Authenticator(
client_id=user,
client_secret=passwd,
token_refresh_endpoint=oauth_token_api,
refresh_token=None
),
server_url="<http://localhost:8000/api/v1/workspaces/list>"
_`#url_params=parameter`_
)
I get the error message "AttributeError: 'Oauth2Authenticator' object has no attribute '__dataclass_fields__'" and "TypeError: must be called with a dataclass type or instance"
u
Sorry @Christian Schawe, I seem to be having a bit of trouble. Don't worry though, I've pinged my support folks and they will try to fix me up! 🧑‍💻 Perhaps try again in 5mins?