bug: sharepoint target address from automation feature
This commit is contained in:
parent
125c2bbce7
commit
d78f071682
1 changed files with 16 additions and 3 deletions
|
|
@ -45,11 +45,24 @@ class ApiClientHelper:
|
||||||
Dict with API response or error information
|
Dict with API response or error information
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not hasattr(self.services, 'sharepoint') or not self.services.sharepoint._target.accessToken:
|
sp = getattr(self.services, 'sharepoint', None)
|
||||||
|
if not sp:
|
||||||
return {"error": "SharePoint service not configured with access token"}
|
return {"error": "SharePoint service not configured with access token"}
|
||||||
|
# Service center: accessToken on service directly. Legacy: wrapped in PublicService._target
|
||||||
|
try:
|
||||||
|
access_token = getattr(sp, 'accessToken', None)
|
||||||
|
if access_token is None:
|
||||||
|
target = getattr(sp, '_target', None) # Only legacy hub has _target
|
||||||
|
if target is not None:
|
||||||
|
access_token = getattr(target, 'accessToken', None)
|
||||||
|
except AttributeError as ae:
|
||||||
|
logger.warning(f"SharePoint token extraction failed: {ae}")
|
||||||
|
return {"error": "SharePoint service not configured with access token"}
|
||||||
|
if not access_token:
|
||||||
|
return {"error": "SharePoint service not configured with access token"}
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {self.services.sharepoint._target.accessToken}",
|
"Authorization": f"Bearer {access_token}",
|
||||||
"Content-Type": "application/json" if data and method != "PUT" else "application/octet-stream" if data else "application/json"
|
"Content-Type": "application/json" if data and method != "PUT" else "application/octet-stream" if data else "application/json"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue