Skip to content

Commit

Permalink
GAds oauth demo (#5996)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifnada authored Sep 13, 2021
1 parent a3be0b4 commit a50073e
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 107 deletions.
92 changes: 46 additions & 46 deletions airbyte-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,29 @@ paths:
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/source_oauths/oauth_params/create:
post:
tags:
- oauth
summary: >
Sets instancewide variables to be used for the oauth flow when creating this source. When set, these variables will be injected
into a connector's configuration before any interaction with the connector image itself. This enables running oauth flows with
consistent variables e.g: the company's Google Ads developer_token, client_id, and client_secret without the user having to know
about these variables.
operationId: setInstancewideSourceOauthParams
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SetInstancewideSourceOauthParamsRequestBody"
required: true
responses:
"200":
description: Successful
"400":
$ref: "#/components/responses/ExceptionResponse"
"404":
$ref: "#/components/responses/NotFoundResponse"
/v1/source_oauths/get_consent_url:
post:
tags:
Expand Down Expand Up @@ -1276,6 +1299,29 @@ paths:
$ref: "#/components/responses/NotFoundResponse"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/destination_oauths/oauth_params/create:
post:
tags:
- oauth
summary: >
Sets instancewide variables to be used for the oauth flow when creating this destination. When set, these variables will be injected
into a connector's configuration before any interaction with the connector image itself. This enables running oauth flows with
consistent variables e.g: the company's Google Ads developer_token, client_id, and client_secret without the user having to know
about these variables.
operationId: setInstancewideDestinationOauthParams
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SetInstancewideDestinationOauthParamsRequestBody"
required: true
responses:
"200":
description: Successful
"400":
$ref: "#/components/responses/ExceptionResponse"
"404":
$ref: "#/components/responses/NotFoundResponse"
/v1/web_backend/connections/list:
post:
tags:
Expand Down Expand Up @@ -1620,52 +1666,6 @@ paths:
$ref: "#/components/schemas/ImportRead"
"404":
$ref: "#/components/responses/NotFoundResponse"
/v1/source_oauths/oauth_params/create:
post:
tags:
- oauth
summary: >
Sets instancewide variables to be used for the oauth flow when creating this source. When set, these variables will be injected
into a connector's configuration before any interaction with the connector image itself. This enables running oauth flows with
consistent variables e.g: the company's Google Ads developer_token, client_id, and client_secret without the user having to know
about these variables.
operationId: setInstancewideSourceOauthParams
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SetInstancewideSourceOauthParamsRequestBody"
required: true
responses:
"200":
description: Successful
"400":
$ref: "#/components/responses/ExceptionResponse"
"404":
$ref: "#/components/responses/NotFoundResponse"
/v1/destination_oauths/oauth_params/create:
post:
tags:
- oauth
summary: >
Sets instancewide variables to be used for the oauth flow when creating this destination. When set, these variables will be injected
into a connector's configuration before any interaction with the connector image itself. This enables running oauth flows with
consistent variables e.g: the company's Google Ads developer_token, client_id, and client_secret without the user having to know
about these variables.
operationId: setInstancewideDestinationOauthParams
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SetInstancewideDestinationOauthParamsRequestBody"
required: true
responses:
"200":
description: Successful
"400":
$ref: "#/components/responses/ExceptionResponse"
"404":
$ref: "#/components/responses/NotFoundResponse"
components:
securitySchemes:
bearerAuth:
Expand Down
1 change: 0 additions & 1 deletion airbyte-oauth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ dependencies {
implementation project(':airbyte-config:models')
implementation project(':airbyte-config:persistence')
implementation project(':airbyte-json-validation')

testImplementation project(':airbyte-oauth')
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import com.google.common.collect.ImmutableMap;
import io.airbyte.config.persistence.ConfigRepository;
import io.airbyte.oauth.google.GoogleAdsOauthFlow;
import io.airbyte.oauth.google.GoogleAnalyticsOauthFlow;
import java.util.Map;

public class OAuthImplementationFactory {
Expand All @@ -34,7 +36,8 @@ public class OAuthImplementationFactory {

public OAuthImplementationFactory(ConfigRepository configRepository) {
OAUTH_FLOW_MAPPING = ImmutableMap.<String, OAuthFlowImplementation>builder()
.put("airbyte/source-google-analytics-v4", new GoogleOAuthFlow(configRepository))
.put("airbyte/source-google-analytics-v4", new GoogleAnalyticsOauthFlow(configRepository))
.put("airbyte/source-google-ads", new GoogleAdsOauthFlow(configRepository))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* MIT License
*
* Copyright (c) 2020 Airbyte
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.airbyte.oauth.google;

import com.fasterxml.jackson.databind.JsonNode;
import io.airbyte.config.persistence.ConfigRepository;

public class GoogleAdsOauthFlow extends GoogleOAuthFlow {

public GoogleAdsOauthFlow(ConfigRepository configRepository) {
super(configRepository, "https://www.googleapis.com/auth/adwords");
}

@Override
protected String getClientIdUnsafe(JsonNode config) {
// the config object containing client ID and secret is nested inside the "credentials" object
return super.getClientIdUnsafe(config.get("credentials"));
}

@Override
protected String getClientSecretUnsafe(JsonNode config) {
// the config object containing client ID and secret is nested inside the "credentials" object
return super.getClientSecretUnsafe(config.get("credentials"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
*
* Copyright (c) 2020 Airbyte
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.airbyte.oauth.google;

import io.airbyte.config.persistence.ConfigRepository;

public class GoogleAnalyticsOauthFlow extends GoogleOAuthFlow {

public GoogleAnalyticsOauthFlow(ConfigRepository configRepository) {
super(configRepository, "https://www.googleapis.com/auth/analytics.readonly");
}

}
Loading

0 comments on commit a50073e

Please sign in to comment.