Skip to content

Commit

Permalink
source-google-drive: add declarative Oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
aldogonzalez8 committed Feb 6, 2025
1 parent 9a9c23c commit 6bc7f4a
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, Mapping, Optional

from airbyte_cdk import AdvancedAuth, ConfiguredAirbyteCatalog, ConnectorSpecification, OAuthConfigSpecification, TState
from airbyte_cdk.models import AuthFlowType
from airbyte_cdk.models import AuthFlowType, OauthConnectorInputSpecification
from airbyte_cdk.sources.file_based.file_based_source import FileBasedSource
from airbyte_cdk.sources.file_based.stream.cursor.default_file_based_cursor import DefaultFileBasedCursor
from source_google_drive.spec import SourceGoogleDriveSpec
Expand All @@ -28,6 +28,11 @@ def spec(self, *args: Any, **kwargs: Any) -> ConnectorSpecification:
"""
Returns the specification describing what fields can be configured by a user when setting up a file-based source.
"""
oauth_connector_input_specification = OauthConnectorInputSpecification(
consent_url="https://accounts.google.com/o/oauth2/v2/auth?{{client_id_param}}&{{redirect_uri_param}}&response_type=code&{{scope_param}}&access_type=offline&{{state_param}}&include_granted_scopes=true&prompt=consent",
access_token_url="https://oauth2.googleapis.com/token?{{client_id_param}}&{{client_secret_param}}&{{auth_code_param}}&{{redirect_uri_param}}&grant_type=authorization_code",
scope="https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/admin.directory.group.readonly https://www.googleapis.com/auth/admin.directory.group.member.readonly https://www.googleapis.com/auth/admin.directory.user.readonly",
)

return ConnectorSpecification(
documentationUrl=self.spec_class.documentation_url(),
Expand All @@ -37,10 +42,17 @@ def spec(self, *args: Any, **kwargs: Any) -> ConnectorSpecification:
predicate_key=["credentials", "auth_type"],
predicate_value="Client",
oauth_config_specification=OAuthConfigSpecification(
oauth_connector_input_specification=oauth_connector_input_specification,
complete_oauth_output_specification={
"type": "object",
"additionalProperties": False,
"properties": {"refresh_token": {"type": "string", "path_in_connector_config": ["credentials", "refresh_token"]}},
"properties": {
"refresh_token": {
"type": "string",
"path_in_connector_config": ["credentials", "refresh_token"],
"path_in_oauth_response": ["refresh_token"],
}
},
},
complete_oauth_server_input_specification={
"type": "object",
Expand Down

0 comments on commit 6bc7f4a

Please sign in to comment.