Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAds oauth demo #5996

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were just moved for grouping with other oauth endpoints. no actual changes happened here.

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
2 changes: 1 addition & 1 deletion airbyte-oauth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
dependencies {
implementation project(':airbyte-config:models')
implementation project(':airbyte-config:persistence')
testImplementation project(':airbyte-oauth')
sherifnada marked this conversation as resolved.
Show resolved Hide resolved
implementation project(':airbyte-json-validation')

sherifnada marked this conversation as resolved.
Show resolved Hide resolved
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");
Copy link
Contributor

@ChristopheDuong ChristopheDuong Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw the GoogleAnalytics scope URL is encoded as https%3A//. We should probably handle URL encoding of query params automatically in the abstract class...

Copy link
Contributor

@ChristopheDuong ChristopheDuong Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduce some additional code to handle these in #6018

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. done

}

@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%3A//www.googleapis.com/auth/analytics.readonly");
Copy link
Contributor

@ChristopheDuong ChristopheDuong Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
super(configRepository, "https%3A//www.googleapis.com/auth/analytics.readonly");
super(configRepository, "https://www.googleapis.com/auth/analytics.readonly");

}

}
Loading