|
request_success, response = execute_gql_request(query, variables) |
There's no inherent check in the GQL to actually provide feedback which would ascertain if the key or partner can actually access this endpoint. Running this gives me a native key error:
TTD/Platform-main/Python/ThirdPartyData/GetAllThirdPartyDataForPartnerGQL.py", line 284, in query_partner_third_party_data
partner_provider_data = get_user_third_party_data_providers()
...
TTD/Platform-main/Python/ThirdPartyData/GetAllThirdPartyDataForPartnerGQL.py", line 166, in get_user_third_party_data_providers
nodes = response.data["partner"]["thirdPartyDataProviders"]["nodes"]
~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'partner'
After throwing in some logging lines, I was able to see the following:
GQL response data: {}
GQL response errors: [{'message': 'Unauthorized field or type', 'path': ['partner', 'thirdPartyDataProviders'], 'extensions': {'code': 'UNAUTHORIZED_FIELD_OR_TYPE'}}]
Traceback (most recent call last):
I suggest something such as this:
if not request_success:
print("GraphQL request did not return a successful HTTP status (non-2xx).")
print("Likely an invalid token or incorrect environment URL.")
# Optionally print out the response or errors for more detail
print(f"GQL Errors: {response.errors}")
raise Exception("Request failed; verify your credentials or environment.")
if response.errors:
# Example: Look for unauthorized access errors
for err in response.errors:
code = err.get("extensions", {}).get("code", "")
if code == "UNAUTHORIZED_FIELD_OR_TYPE":
print("You do not have permission to access this field/type.")
print("Check your token, seat-level role, or partner-level permissions.")
raise Exception("Unauthorized field or type. Invalid credentials or insufficient permissions.")
# If there are other errors, surface them too
print("GraphQL reported errors:", response.errors)
raise Exception("GraphQL errors encountered. Please review the details above.")`
Platform/Python/ThirdPartyData/GetAllThirdPartyDataForPartnerGQL.py
Line 152 in 9bb26e2
There's no inherent check in the GQL to actually provide feedback which would ascertain if the key or partner can actually access this endpoint. Running this gives me a native key error:
After throwing in some logging lines, I was able to see the following:
GQL response data: {} GQL response errors: [{'message': 'Unauthorized field or type', 'path': ['partner', 'thirdPartyDataProviders'], 'extensions': {'code': 'UNAUTHORIZED_FIELD_OR_TYPE'}}] Traceback (most recent call last):I suggest something such as this: