@@ -42,14 +42,16 @@ def get_app_only_access_token(self):
4242 url_info = urlparse (self .url )
4343 return self ._get_app_only_access_token (url_info .hostname , realm )
4444 except requests .exceptions .RequestException as e :
45- self .error = e .response .text if e .response else None
45+ self .error = e .response .text if e .response is not None else "Acquire app-only access token failed."
4646 raise ValueError (self .error )
4747
4848 def _get_app_only_access_token (self , target_host , target_realm ):
4949 """
50+ Retrieves an app-only access token from ACS to call the specified principal
51+ at the specified targetHost. The targetHost must be registered for target principal.
5052
51- :type target_host: str
52- :type target_realm: str
53+ :param str target_host: Url authority of the target principal
54+ :param str target_realm: Realm to use for the access token's nameid and audience
5355 """
5456 resource = self .get_formatted_principal (self .SharePointPrincipal , target_host , target_realm )
5557 principal_id = self .get_formatted_principal (self ._client_id , None , target_realm )
@@ -67,11 +69,15 @@ def _get_app_only_access_token(self, target_host, target_realm):
6769 return TokenResponse .from_json (response .json ())
6870
6971 def _get_realm_from_target_url (self ):
72+ """Get the realm for the URL"""
7073 response = requests .head (url = self .url , headers = {'Authorization' : 'Bearer' })
7174 return self .process_realm_response (response )
7275
7376 @staticmethod
7477 def process_realm_response (response ):
78+ """
79+ :type response: requests.Response
80+ """
7581 header_key = "WWW-Authenticate"
7682 if header_key in response .headers :
7783 auth_values = response .headers [header_key ].split ("," )
0 commit comments