Skip to content

Commit

Permalink
remove access token thats unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Mar 11, 2024
1 parent 23fa1ae commit 1b12f26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ A full list of supported settings and capabilities is available by running: `tap

If you're setting up `tap-google-analytics` for your own organization and only plan to extract from a handful of different views in the same limited set of properties, Service Account based authorization is the simplest. When you create a service account Google gives you a json file with that service account's credentials called the `client_secrets.json`, and that's all you need to pass to this tap, and you only have to do it once, so this is the recommended way of configuring `tap-google-analytics`.

If you're building something where a wide variety of users need to be able to give access to their Google Analytics, `tap-google-analytics` can use an `access_token` granted by those users to authorize it's requests to Google. This `access_token` is produced by a normal Google OAuth flow, but this flow is outside the scope of `tap-google-analytics`. This is useful if you're integrating `tap-google-analytics` with another system, like Stitch Data might do to allow users to configure their extracts themselves without manual config setup. This tap expects an `access_token`, `refresh_token`, `client_id` and `client_secret` to be passed to it in order to authenticate as the user who granted the token and then access their data.
If you're building something where a wide variety of users need to be able to give access to their Google Analytics, `tap-google-analytics` can use an `access_token` granted by those users to authorize it's requests to Google. This `access_token` is produced by a normal Google OAuth flow, but this flow is outside the scope of `tap-google-analytics`. This is useful if you're integrating `tap-google-analytics` with another system, like Arch does to allow users to configure their extracts themselves without manual config setup. This tap expects a `refresh_token`, `client_id` and `client_secret` to be passed to it in order to authenticate as the user who granted the token and then access their data.

## Required Analytics Reporting APIs & OAuth Scopes

Expand Down
17 changes: 6 additions & 11 deletions tap_google_analytics/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ class TapGoogleAnalytics(Tap):
th.Property(
"oauth_credentials",
th.ObjectType(
th.Property(
"access_token",
th.StringType,
description="Google Analytics Access Token",
),
th.Property(
"refresh_token",
th.StringType,
Expand Down Expand Up @@ -120,12 +115,12 @@ class TapGoogleAnalytics(Tap):

def _initialize_credentials(self):
if self.config.get("oauth_credentials"):
return OAuthCredentials(
token=self.config["oauth_credentials"]["access_token"],
refresh_token=self.config["oauth_credentials"]["refresh_token"],
client_id=self.config["oauth_credentials"]["client_id"],
client_secret=self.config["oauth_credentials"]["client_secret"],
token_uri="https://accounts.google.com/o/oauth2/token", # noqa: S106
return OAuthCredentials.from_authorized_user_info(
{
"client_id": self.config["oauth_credentials"]["client_id"],
"client_secret": self.config["oauth_credentials"]["client_secret"],
"refresh_token": self.config["oauth_credentials"]["refresh_token"],
}
)

if self.config.get("key_file_location"):
Expand Down

0 comments on commit 1b12f26

Please sign in to comment.