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

Error when registering custom auth class #2263

Open
CharlesRngrd opened this issue Feb 4, 2025 · 0 comments
Open

Error when registering custom auth class #2263

CharlesRngrd opened this issue Feb 4, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@CharlesRngrd
Copy link

dlt version

1.6.0

Describe the problem

Hi,

It seems the custom authentication registration is boken.

When I use, the CustomAuth like bellow, it works:

"auth": CustomAuth(
    url=dlt.secrets["sources.eurecia.base_url"],
    token=dlt.secrets["sources.eurecia.authorization"],
),

But when I try to register the same CustomAuth like this, I face a validation error :

register_auth("custom_auth", CustomAuth)

"auth": {
    "type": "custom_auth",
    "url": dlt.secrets["sources.eurecia.base_url"],
    "token": dlt.secrets["sources.eurecia.authorization"],
},

dlt.common.exceptions.DictValidationException: In path ./client: field 'auth' expects the following types: AuthConfigBase, Literal, BearerTokenAuth, BearerTokenAuthConfig, APIKeyAuth, ApiKeyAuthConfig, HttpBasicAuth, HttpBasicAuthConfig, OAuth2ClientCredentials, OAuth2ClientCredentialsConfig. Provided value {'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o8'} with type 'dict' is invalid with the following errors:
For BearerTokenAuthConfig: In path ./client/auth: following fields are unexpected {'url'}
For ApiKeyAuthConfig: In path ./client/auth: following required fields are missing {'api_key'}
For HttpBasicAuthConfig: In path ./client/auth: following required fields are missing {'username', 'password'}
For OAuth2ClientCredentialsConfig: In path ./client/auth: following required fields are missing {'client_secret', 'client_id', 'access_token_url'}
For AuthConfigBase: In path ./client: field 'auth' expects callable (function or class instance) but got '{'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o
8'}'. Mind that signatures are not validated
For Literal: In path ./client: field 'auth' with value {'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o8'} is not one of: ['bearer', 'api_key', 'http_basic', 'oauth2_client_credentials', 'custom_auth']
For BearerTokenAuth: In path ./client: field 'auth' expects callable (function or class instance) but got '{'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o
8'}'. Mind that signatures are not validated
For APIKeyAuth: In path ./client: field 'auth' expects callable (function or class instance) but got '{'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o8'}'. Mind that signatures are not validated
For HttpBasicAuth: In path ./client: field 'auth' expects callable (function or class instance) but got '{'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o
8'}'. Mind that signatures are not validated
For OAuth2ClientCredentials: In path ./client: field 'auth' expects callable (function or class instance) but got '{'type': 'custom_auth', 'url': 'https://api.eurecia.com/eurecia', 'token': 'o*****8'}'. Mind that signatures are not validated

Expected behavior

No response

Steps to reproduce

Create a fake CustomAuth class that expects both a url and a token parameter.

Then try to register it. You may reproduce the error.

Operating system

Windows

Runtime environment

Local

Python version

3.12

dlt data source

No response

dlt destination

No response

Other deployment details

No response

Additional information

No response

@burnash burnash self-assigned this Feb 4, 2025
@burnash burnash added the bug Something isn't working label Feb 4, 2025
@rudolfix rudolfix moved this from Todo to In Progress in dlt core library Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

2 participants