-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
source-google-ads: upgrade to estuary CDK
- Loading branch information
1 parent
a489f84
commit cdcdf50
Showing
66 changed files
with
1,096 additions
and
1,437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import estuary_cdk.pydantic_polyfill # Must be first. | ||
|
||
import asyncio | ||
from estuary_cdk import shim_airbyte_cdk, flow | ||
from source_google_ads import SourceGoogleAds | ||
import json | ||
|
||
|
||
def wrap_with_braces(body: str, count: int): | ||
opening = "{" * count | ||
closing = "}" * count | ||
return f"{opening}{body}{closing}" | ||
|
||
|
||
def urlencode_field(field: str): | ||
return f"{wrap_with_braces('#urlencode',2)}{wrap_with_braces(field,3)}{wrap_with_braces('/urlencode',2)}" | ||
|
||
|
||
accessTokenBody = { | ||
"grant_type": "authorization_code", | ||
"client_id": "{{{ client_id }}}", | ||
"client_secret": "{{{ client_secret }}}", | ||
"redirect_uri": "{{{ redirect_uri }}}", | ||
"code": "{{{ code }}}", | ||
} | ||
|
||
asyncio.run( | ||
shim_airbyte_cdk.CaptureShim( | ||
delegate=SourceGoogleAds(), | ||
oauth2=flow.OAuth2Spec( | ||
provider="google", | ||
accessTokenBody=json.dumps(accessTokenBody), | ||
authUrlTemplate=( | ||
f"https://accounts.google.com/o/oauth2/auth?" | ||
f"access_type=offline&" | ||
f"prompt=consent&" | ||
f"client_id={urlencode_field('client_id')}&" | ||
f"redirect_uri={urlencode_field('redirect_uri')}&" | ||
f"response_type=code&" | ||
f"scope=https://www.googleapis.com/auth/adwords&state={urlencode_field('state')}" | ||
), | ||
accessTokenResponseMap={"refresh_token": "/refresh_token"}, | ||
accessTokenUrlTemplate="https://oauth2.googleapis.com/token", | ||
accessTokenHeaders={}, | ||
), | ||
schema_inference=True, | ||
).serve() | ||
) |
Oops, something went wrong.