-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
GAds oauth demo #5996
Conversation
@@ -1184,6 +1184,29 @@ paths: | |||
$ref: "#/components/responses/NotFoundResponse" | |||
"422": | |||
$ref: "#/components/responses/InvalidInputResponse" | |||
/v1/source_oauths/oauth_params/create: |
There was a problem hiding this comment.
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.
@@ -69,15 +74,32 @@ public JsonNode injectDestinationOAuthParameters(UUID destinationDefinitionId, U | |||
} | |||
} | |||
|
|||
private void injectJsonNode(ObjectNode config, ObjectNode fromConfig) { | |||
@VisibleForTesting | |||
void injectJsonNode(ObjectNode mainConfig, ObjectNode fromConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was cumbersome to test this via the calling methods so I exposed it here. Open to changing this if we think it's a bad idea.
public class GoogleAdsOauthFlow extends GoogleOAuthFlow { | ||
|
||
public GoogleAdsOauthFlow(ConfigRepository configRepository) { | ||
super(configRepository, "https://www.googleapis.com/auth/adwords"); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. done
private final String consentUrl = "https://accounts.google.com/o/oauth2/v2/auth"; | ||
private final String accessTokenUrl = "https://oauth2.googleapis.com/token"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious to know why these were changed from constant strings to attributes to the class?
Is it because you expect in the future to override these values when extending the base class maybe? In that case, is it more clear to initialize these in the constructor (as it is done with googleQueryParameters
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially had them that way but then realized it's probably not going to be injected separately by each connector. Moved it back to static
public class GoogleAnalyticsOauthFlow extends GoogleOAuthFlow { | ||
|
||
public GoogleAnalyticsOauthFlow(ConfigRepository configRepository) { | ||
super(configRepository, "https%3A//www.googleapis.com/auth/analytics.readonly"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super(configRepository, "https%3A//www.googleapis.com/auth/analytics.readonly"); | |
super(configRepository, "https://www.googleapis.com/auth/analytics.readonly"); |
// TODO state should be randomly generated, and the 2nd step of oauth should verify its value | ||
// matches the initially generated state value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, the state value should be returned by the getConsentUrl
and then, forwarded by the UI back to the completeOAuthFlow
API endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just passing the full "consentUrl" in the call from the UI? but that requires storing some state on that side.
…hq/airbyte into sherif/oauth-google-analytics-v2
What
This branch contains working code for demoing oauth with Google Ads. It builds on the branch
chris/google-analytics-oauth
(#5911).How
GoogleOauthFlow
as a superclass to perform oauth for all google connectors. The main changes are: injectingscope
from the child class, and allowing the child class to specify how to parse the instancewide config to get client ID and client secret.OauthConfigSupplier.injectConfig
to handle merging nested configs. Previously it overwrote any keys. Now it merges any objects with their equivalent objects if they exist, prioritizing thefromConfig
. This was needed to work with google ads as the connector nests its credentials inside the config.Recommended reading order
For points 1 & 2:
GoogleAnalyticsOauthFlow.java
GoogleAdsOauthFlow.java
GoogleOauthFlow.java
For point 3:
OAuthConfigSupplier.java
,OAuthConfigSupplierTest.java
Important Learnings from this PR
It uncovered a few points for improvement: