Remove lowcode SingleUseRefreshTokenOauthAuthenticator (#27053)
* wip * Automated Commit - Formatting Changes * add documentation * tests and fixes * fix tests * more documentation * revert * changes as discussed * fix case * add docstring * add details to schema * format * remove old singleuserefreshtokenauthenticator from lowcode * prepare quickbooks connector * format --------- Co-authored-by: flash1293 <flash1293@users.noreply.github.com>
This commit is contained in:
@@ -776,124 +776,6 @@ definitions:
|
||||
$parameters:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
SingleUseRefreshTokenOAuthAuthenticator:
|
||||
tile: OAuth 2.0 With Single-Use Refresh Token
|
||||
description: Authenticator for requests using OAuth 2.0 authentication with a single use refresh token.
|
||||
type: object
|
||||
required:
|
||||
- type
|
||||
- token_refresh_endpoint
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [SingleUseRefreshTokenOAuthAuthenticator]
|
||||
token_refresh_endpoint:
|
||||
title: Token Refresh Endpoint
|
||||
description: Endpoint to send a POST request in order to get a new access token.
|
||||
type: string
|
||||
examples:
|
||||
- https://connect.squareup.com/oauth2/token
|
||||
client_id_config_path:
|
||||
title: Config Path To Client ID
|
||||
description: Config path to the client ID.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: ["credentials", "client_id"]
|
||||
examples:
|
||||
- ["credentials", "client_id"]
|
||||
- ["client_id"]
|
||||
client_secret_config_path:
|
||||
title: Config Path To Client Secret
|
||||
description: Config path to the client secret.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: ["credentials", "client_secret"]
|
||||
examples:
|
||||
- ["credentials", "client_secret"]
|
||||
- ["client_secret"]
|
||||
access_token_config_path:
|
||||
title: Config Path To Access Token
|
||||
description: Config path to the access token.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: ["credentials", "access_token"]
|
||||
examples:
|
||||
- ["credentials", "access_token"]
|
||||
- ["access_token"]
|
||||
refresh_token_config_path:
|
||||
title: Config Path To Refresh Token
|
||||
description: Config path to the access token.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: ["credentials", "refresh_token"]
|
||||
examples:
|
||||
- ["credentials", "refresh_token"]
|
||||
- ["refresh_token"]
|
||||
token_expiry_date_config_path:
|
||||
title: Config Path To Expiry Date
|
||||
description: Config path to the expiry date.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default: ["credentials", "token_expiry_date"]
|
||||
examples:
|
||||
- ["credentials", "token_expiry_date"]
|
||||
access_token_name:
|
||||
title: Access Token Response Field Name
|
||||
description: The name of the field to extract the access token from in the token refresh response.
|
||||
type: string
|
||||
default: "access_token"
|
||||
examples:
|
||||
- "access_token"
|
||||
refresh_token_name:
|
||||
title: Refresh Token Response Field Name
|
||||
type: string
|
||||
default: "refresh_token"
|
||||
examples:
|
||||
- "refresh_token"
|
||||
expires_in_name:
|
||||
title: Time To Expiration Response Field Name
|
||||
description: The name of the field the extract the number of seconds the access token will be valid from the token refresh response.
|
||||
type: string
|
||||
default: "expires_in"
|
||||
examples:
|
||||
- "expires_in"
|
||||
grant_type:
|
||||
title: Grant Type
|
||||
description: Specifies the OAuth2 grant type. If set to refresh_token, the refresh_token needs to be provided as well. For client_credentials, only client id and secret are required. Other grant types are not officially supported.
|
||||
type: string
|
||||
default: "refresh_token"
|
||||
examples:
|
||||
- refresh_token
|
||||
- client_credentials
|
||||
refresh_request_body:
|
||||
title: Refresh Request Body
|
||||
description: Body of the request sent to get a new access token.
|
||||
type: object
|
||||
additionalProperties: true
|
||||
examples:
|
||||
- applicationId: "{{ config['application_id'] }}"
|
||||
applicationSecret: "{{ config['application_secret'] }}"
|
||||
token: "{{ config['token'] }}"
|
||||
scopes:
|
||||
title: Scopes
|
||||
description: List of scopes that should be granted to the access token.
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
examples:
|
||||
- [
|
||||
"crm.list.read",
|
||||
"crm.objects.contacts.read",
|
||||
"crm.schema.contacts.read",
|
||||
]
|
||||
$parameters:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
DeclarativeStream:
|
||||
title: Declarative Stream
|
||||
description: A stream whose behavior is described by a set of declarative low code components.
|
||||
@@ -1121,7 +1003,6 @@ definitions:
|
||||
- "$ref": "#/definitions/BearerAuthenticator"
|
||||
- "$ref": "#/definitions/CustomAuthenticator"
|
||||
- "$ref": "#/definitions/OAuthAuthenticator"
|
||||
- "$ref": "#/definitions/SingleUseRefreshTokenOAuthAuthenticator"
|
||||
- "$ref": "#/definitions/NoAuth"
|
||||
- "$ref": "#/definitions/SessionTokenAuthenticator"
|
||||
error_handler:
|
||||
|
||||
@@ -375,88 +375,6 @@ class OAuthAuthenticator(BaseModel):
|
||||
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
||||
|
||||
|
||||
class SingleUseRefreshTokenOAuthAuthenticator(BaseModel):
|
||||
type: Literal["SingleUseRefreshTokenOAuthAuthenticator"]
|
||||
token_refresh_endpoint: str = Field(
|
||||
...,
|
||||
description="Endpoint to send a POST request in order to get a new access token.",
|
||||
examples=["https://connect.squareup.com/oauth2/token"],
|
||||
title="Token Refresh Endpoint",
|
||||
)
|
||||
client_id_config_path: Optional[List[str]] = Field(
|
||||
["credentials", "client_id"],
|
||||
description="Config path to the client ID.",
|
||||
examples=[["credentials", "client_id"], ["client_id"]],
|
||||
title="Config Path To Client ID",
|
||||
)
|
||||
client_secret_config_path: Optional[List[str]] = Field(
|
||||
["credentials", "client_secret"],
|
||||
description="Config path to the client secret.",
|
||||
examples=[["credentials", "client_secret"], ["client_secret"]],
|
||||
title="Config Path To Client Secret",
|
||||
)
|
||||
access_token_config_path: Optional[List[str]] = Field(
|
||||
["credentials", "access_token"],
|
||||
description="Config path to the access token.",
|
||||
examples=[["credentials", "access_token"], ["access_token"]],
|
||||
title="Config Path To Access Token",
|
||||
)
|
||||
refresh_token_config_path: Optional[List[str]] = Field(
|
||||
["credentials", "refresh_token"],
|
||||
description="Config path to the access token.",
|
||||
examples=[["credentials", "refresh_token"], ["refresh_token"]],
|
||||
title="Config Path To Refresh Token",
|
||||
)
|
||||
token_expiry_date_config_path: Optional[List[str]] = Field(
|
||||
["credentials", "token_expiry_date"],
|
||||
description="Config path to the expiry date.",
|
||||
examples=[["credentials", "token_expiry_date"]],
|
||||
title="Config Path To Expiry Date",
|
||||
)
|
||||
access_token_name: Optional[str] = Field(
|
||||
"access_token",
|
||||
description="The name of the field to extract the access token from in the token refresh response.",
|
||||
examples=["access_token"],
|
||||
title="Access Token Response Field Name",
|
||||
)
|
||||
refresh_token_name: Optional[str] = Field(
|
||||
"refresh_token",
|
||||
examples=["refresh_token"],
|
||||
title="Refresh Token Response Field Name",
|
||||
)
|
||||
expires_in_name: Optional[str] = Field(
|
||||
"expires_in",
|
||||
description="The name of the field the extract the number of seconds the access token will be valid from the token refresh response.",
|
||||
examples=["expires_in"],
|
||||
title="Time To Expiration Response Field Name",
|
||||
)
|
||||
grant_type: Optional[str] = Field(
|
||||
"refresh_token",
|
||||
description="Specifies the OAuth2 grant type. If set to refresh_token, the refresh_token needs to be provided as well. For client_credentials, only client id and secret are required. Other grant types are not officially supported.",
|
||||
examples=["refresh_token", "client_credentials"],
|
||||
title="Grant Type",
|
||||
)
|
||||
refresh_request_body: Optional[Dict[str, Any]] = Field(
|
||||
None,
|
||||
description="Body of the request sent to get a new access token.",
|
||||
examples=[
|
||||
{
|
||||
"applicationId": "{{ config['application_id'] }}",
|
||||
"applicationSecret": "{{ config['application_secret'] }}",
|
||||
"token": "{{ config['token'] }}",
|
||||
}
|
||||
],
|
||||
title="Refresh Request Body",
|
||||
)
|
||||
scopes: Optional[List[str]] = Field(
|
||||
None,
|
||||
description="List of scopes that should be granted to the access token.",
|
||||
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
|
||||
title="Scopes",
|
||||
)
|
||||
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
||||
|
||||
|
||||
class ExponentialBackoffStrategy(BaseModel):
|
||||
type: Literal["ExponentialBackoffStrategy"]
|
||||
factor: Optional[Union[float, str]] = Field(
|
||||
@@ -1098,7 +1016,6 @@ class HttpRequester(BaseModel):
|
||||
BearerAuthenticator,
|
||||
CustomAuthenticator,
|
||||
OAuthAuthenticator,
|
||||
SingleUseRefreshTokenOAuthAuthenticator,
|
||||
NoAuth,
|
||||
SessionTokenAuthenticator,
|
||||
]
|
||||
|
||||
@@ -9,7 +9,6 @@ import inspect
|
||||
import re
|
||||
from typing import Any, Callable, List, Literal, Mapping, Optional, Type, Union, get_args, get_origin, get_type_hints
|
||||
|
||||
import dpath
|
||||
from airbyte_cdk.sources.declarative.auth import DeclarativeOauth2Authenticator
|
||||
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import NoAuth
|
||||
from airbyte_cdk.sources.declarative.auth.oauth import DeclarativeSingleUseRefreshTokenOauth2Authenticator
|
||||
@@ -74,9 +73,6 @@ from airbyte_cdk.sources.declarative.models.declarative_component_schema import
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import RequestPath as RequestPathModel
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import SessionTokenAuthenticator as SessionTokenAuthenticatorModel
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import SimpleRetriever as SimpleRetrieverModel
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
|
||||
SingleUseRefreshTokenOAuthAuthenticator as SingleUseRefreshTokenOAuthAuthenticatorModel,
|
||||
)
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import Spec as SpecModel
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import SubstreamPartitionRouter as SubstreamPartitionRouterModel
|
||||
from airbyte_cdk.sources.declarative.models.declarative_component_schema import WaitTimeFromHeader as WaitTimeFromHeaderModel
|
||||
@@ -104,7 +100,6 @@ from airbyte_cdk.sources.declarative.stream_slicers import CartesianProductStrea
|
||||
from airbyte_cdk.sources.declarative.transformations import AddFields, RemoveFields
|
||||
from airbyte_cdk.sources.declarative.transformations.add_fields import AddedFieldDefinition
|
||||
from airbyte_cdk.sources.declarative.types import Config
|
||||
from airbyte_cdk.sources.streams.http.requests_native_auth.oauth import SingleUseRefreshTokenOauth2Authenticator
|
||||
from pydantic import BaseModel
|
||||
|
||||
ComponentDefinition: Union[Literal, Mapping, List]
|
||||
@@ -164,7 +159,6 @@ class ModelToComponentFactory:
|
||||
NoAuthModel: self.create_no_auth,
|
||||
NoPaginationModel: self.create_no_pagination,
|
||||
OAuthAuthenticatorModel: self.create_oauth_authenticator,
|
||||
SingleUseRefreshTokenOAuthAuthenticatorModel: self.create_single_use_refresh_token_oauth_authenticator,
|
||||
OffsetIncrementModel: self.create_offset_increment,
|
||||
PageIncrementModel: self.create_page_increment,
|
||||
ParentStreamConfigModel: self.create_parent_stream_config,
|
||||
@@ -695,26 +689,6 @@ class ModelToComponentFactory:
|
||||
parameters=model.parameters,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_single_use_refresh_token_oauth_authenticator(
|
||||
model: SingleUseRefreshTokenOAuthAuthenticatorModel, config: Config, **kwargs
|
||||
) -> SingleUseRefreshTokenOauth2Authenticator:
|
||||
return SingleUseRefreshTokenOauth2Authenticator(
|
||||
config,
|
||||
model.token_refresh_endpoint,
|
||||
access_token_name=model.access_token_name,
|
||||
refresh_token_name=model.refresh_token_name,
|
||||
expires_in_name=model.expires_in_name,
|
||||
client_id=dpath.util.get(config, model.client_id_config_path),
|
||||
client_secret=dpath.util.get(config, model.client_secret_config_path),
|
||||
access_token_config_path=model.access_token_config_path,
|
||||
refresh_token_config_path=model.refresh_token_config_path,
|
||||
token_expiry_date_config_path=model.token_expiry_date_config_path,
|
||||
grant_type=model.grant_type,
|
||||
refresh_request_body=model.refresh_request_body,
|
||||
scopes=model.scopes,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_offset_increment(model: OffsetIncrementModel, config: Config, **kwargs) -> OffsetIncrement:
|
||||
return OffsetIncrement(page_size=model.page_size, config=config, parameters=model.parameters)
|
||||
|
||||
Reference in New Issue
Block a user