-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
airbyte-oauth/src/main/java/io/airbyte/oauth/flows/google/YouTubeAnalyticsOAuthFlow.java
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,46 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.oauth.flows.google; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.common.base.Preconditions; | ||
import io.airbyte.config.persistence.ConfigRepository; | ||
import java.net.http.HttpClient; | ||
import java.util.function.Supplier; | ||
|
||
public class YouTubeAnalyticsOAuthFlow extends GoogleOAuthFlow { | ||
|
||
public static final String SCOPE_URL = "https://www.googleapis.com/auth/yt-analytics.readonly"; | ||
|
||
public YouTubeAnalyticsOAuthFlow(final ConfigRepository configRepository) { | ||
super(configRepository); | ||
} | ||
|
||
@VisibleForTesting | ||
YouTubeAnalyticsOAuthFlow(final ConfigRepository configRepository, final HttpClient httpClient, final Supplier<String> stateSupplier) { | ||
super(configRepository, httpClient, stateSupplier); | ||
} | ||
|
||
@Override | ||
protected String getScope() { | ||
return SCOPE_URL; | ||
} | ||
|
||
@Override | ||
protected String getClientIdUnsafe(final JsonNode config) { | ||
// the config object containing client ID and secret is nested inside the "credentials" object | ||
Preconditions.checkArgument(config.hasNonNull("credentials")); | ||
return super.getClientIdUnsafe(config.get("credentials")); | ||
} | ||
|
||
@Override | ||
protected String getClientSecretUnsafe(final JsonNode config) { | ||
// the config object containing client ID and secret is nested inside the "credentials" object | ||
Preconditions.checkArgument(config.hasNonNull("credentials")); | ||
return super.getClientSecretUnsafe(config.get("credentials")); | ||
} | ||
|
||
} |