diff --git a/README.md b/README.md index b2e829c..4ab0452 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tap_google_analytics/tap.py b/tap_google_analytics/tap.py index a9ebeab..e873b7a 100644 --- a/tap_google_analytics/tap.py +++ b/tap_google_analytics/tap.py @@ -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, @@ -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"):