Skip to content

Commit

Permalink
Merge pull request #95 from jsancho-gpl/master
Browse files Browse the repository at this point in the history
Add methods for tokens in oauth2
  • Loading branch information
jpetrucciani committed Mar 31, 2020
2 parents 331ab7c + fa87715 commit cb8acca
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions hubspot3/oauth2.py
Expand Up @@ -38,7 +38,7 @@ def get_tokens(
redirect_uri: str,
client_id: str = None,
client_secret: str = None,
**options
**options,
):
"""
Request an initial token pair using the provided credentials.
Expand Down Expand Up @@ -69,7 +69,7 @@ def refresh_tokens(
client_id: str = None,
client_secret: str = None,
refresh_token: str = None,
**options
**options,
):
"""
Request a new token pair using the provided refresh token and credentials.
Expand All @@ -93,3 +93,39 @@ def refresh_tokens(
if not client_id and not client_secret and not refresh_token:
self.refresh_token = result["refresh_token"]
return result

def get_access_token_data(self, access_token: str, **options):
"""
Get the meta data for an access token.
:see: https://developers.hubspot.com/docs/methods/oauth2/get-access-token-information
"""
return self._call("access-tokens/{}".format(access_token), **options)

def get_refresh_token_data(self, refresh_token: str = None, **options):
"""
Get the meta data for a refresh token.
If any of the optional parameters are not provided, their value will be read from the
corresponding attributes on this client.
:see: https://developers.hubspot.com/docs/methods/oauth2/get-refresh-token-information
"""
return self._call(
"refresh-tokens/{}".format(refresh_token or self.refresh_token), **options
)

def delete_refresh_token(self, refresh_token: str = None):
"""
Deletes a refresh token. You can use this to delete your refresh token if a user
uninstalls your app.
If any of the optional parameters are not provided, their value will be read from the
corresponding attributes on this client.
:see: https://developers.hubspot.com/docs/methods/oauth2/delete-refresh-token
"""
return self._call(
"refresh-tokens/{}".format(refresh_token or self.refresh_token),
method="DELETE",
)

0 comments on commit cb8acca

Please sign in to comment.