Skip to content

Commit

Permalink
Fixing oauth tap auth due to sdk framework change (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
s7clarke10 authored Sep 4, 2024
1 parent 1d2450a commit f51612e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tap_rest_api_msdk/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ def get_aws_session_client(self):

class ConfigurableOAuthAuthenticator(OAuthAuthenticator):
"""Configurable OAuth Authenticator."""

def get_initial_oauth_token(self):
"""Gets a oauth token for the tap schema discovery.
Requests an oauth token and sets the auth headers.
"""
if not self.is_token_valid():
self.update_access_token()

self.auth_headers["Authorization"] = f"Bearer {self.access_token}"

@property
def oauth_request_body(self) -> dict:
Expand Down
4 changes: 4 additions & 0 deletions tap_rest_api_msdk/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ def get_schema(
# Obtaining Authenticator for authorisation to obtain a schema.
get_authenticator(self)

# Get an initial oauth token if an oauth method
if auth_method == 'oauth':
self._authenticator.get_initial_oauth_token()

headers.update(getattr(self._authenticator, "auth_headers", {}))
params.update(getattr(self._authenticator, "auth_params", {}))

Expand Down

0 comments on commit f51612e

Please sign in to comment.