Skip to content

Commit

Permalink
Remove lowcode SingleUseRefreshTokenOauthAuthenticator (#27053)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Joe Reuter and flash1293 committed Jun 7, 2023
1 parent d3011da commit e19c498
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1098,7 +1016,6 @@ class HttpRequester(BaseModel):
BearerAuthenticator,
CustomAuthenticator,
OAuthAuthenticator,
SingleUseRefreshTokenOAuthAuthenticator,
NoAuth,
SessionTokenAuthenticator,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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
Expand Down Expand Up @@ -74,9 +73,6 @@
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
Expand Down Expand Up @@ -104,7 +100,6 @@
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]
Expand Down Expand Up @@ -164,7 +159,6 @@ def _init_mappings(self):
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,
Expand Down Expand Up @@ -695,26 +689,6 @@ def create_oauth_authenticator(model: OAuthAuthenticatorModel, config: Config, *
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_quickbooks ./source_quickbooks
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=2.0.1
LABEL io.airbyte.version=2.0.2
LABEL io.airbyte.name=airbyte/source-quickbooks
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: cf9c4355-b171-4477-8f2d-6c5cc5fc8b7e
dockerImageTag: 2.0.1
dockerImageTag: 2.0.2
dockerRepository: airbyte/source-quickbooks
githubIssueLabel: source-quickbooks
icon: quickbooks.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ definitions:
"Accept": "application/json"
"User-Agent": "airbyte-connector"
authenticator:
type: SingleUseRefreshTokenOAuthAuthenticator
type: OAuthAuthenticator
token_refresh_endpoint: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
client_id: "{{ config['credentials']['client_id'] }}"
client_secret: "{{ config['credentials']['client_secret'] }}"
refresh_token: "{{ config['credentials']['refresh_token'] }}"
refresh_token_updater: {}
retriever:
type: SimpleRetriever
record_selector:
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/quickbooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ This Source is capable of syncing the following [Streams](https://developer.intu

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:---------------------------------------------------------|
| `2.0.2` | 2023-06-07 | [26722](https://github.com/airbytehq/airbyte/pull/27053) | Update CDK version and adjust authenticator configuration |
| `2.0.1` | 2023-05-28 | [26722](https://github.com/airbytehq/airbyte/pull/26722) | Change datatype for undisclosed amount field in payments |
| `2.0.0` | 2023-04-11 | [25045](https://github.com/airbytehq/airbyte/pull/25045) | Fix datetime format, disable OAuth button in cloud |
| `1.0.0` | 2023-03-20 | [24324](https://github.com/airbytehq/airbyte/pull/24324) | Migrate to Low-Code |
Expand Down

0 comments on commit e19c498

Please sign in to comment.