Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions lumapps/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,28 @@ def _prune(self, method_parts, content):
pop_matches(pth, content)
return content

def get_new_client_as(self, user):
return ApiClient(self._auth_info, self.api_info, user=user)
def get_new_client_as_using_dwd(self, user_email):
""" Get a new ApiClient using domain-wide delegation """
return ApiClient(self._auth_info, self.api_info, user=user_email)

def get_new_client_as(self, user_email, customer_id=None):
""" Get a new ApiClient using an authorized service account by obtaining a
token using the user/getToken method.

Args:
user_email (str): User you want to authenticate on behalf of
customer_id (str): Id of the LumApps customer the user belong to

Returns:
ApiClient: A new instance of the ApiClient correctly authenticated.
"""
if not self.creds:
raise Exception("No credentials (auth_info) provided")
token_infos = self.get_call(
"user/getToken", customerId=customer_id, email=user_email
)
token = token_infos["accessToken"]
return ApiClient(api_info=self.api_info, token=token, user=user_email)

@property
def token(self):
Expand Down