forked from potloc/tap-hubspot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from villagelabsco/feat/VD-4731-oauth
Feat/vd 4731 oauth
- Loading branch information
Showing
3 changed files
with
60 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from singer_sdk.authenticators import OAuthAuthenticator, SingletonMeta | ||
from singer_sdk.streams import RESTStream | ||
from typing import Any, Mapping, TypedDict, TypeGuard | ||
|
||
|
||
class HubSpotOAuthAuthenticator(OAuthAuthenticator, metaclass=SingletonMeta): | ||
def __init__(self, stream: RESTStream) -> None: | ||
super().__init__( | ||
auth_endpoint="https://api.hubapi.com/oauth/v1/token", | ||
stream=stream, | ||
) | ||
|
||
@property | ||
def oauth_request_body(self) -> dict: | ||
return { | ||
"client_id": self.config["client_id"], | ||
"client_secret": self.config["client_secret"], | ||
"grant_type": "refresh_token", | ||
"refresh_token": self.config["refresh_token"], | ||
} | ||
|
||
|
||
class OAuthCredentials(TypedDict): | ||
client_id: str | ||
client_secret: str | ||
refresh_token: str | ||
|
||
|
||
def is_oauth_credentials(value: Mapping[str, Any]) -> TypeGuard[OAuthCredentials]: | ||
return "refresh_token" in value |
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
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