I have the following python code in my PythonScript component:
from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.authentication_context import AuthenticationContext
authority_url = “https://login.microsoftonline.us/<tenant_id>”
site_url = “https://mysite.sharepoint.us/sites/myfolder”
auth_ctx = AuthenticationContext(authority_url)
if auth_ctx.acquire_token_for_app(client_id, client_secret):
ctx = ClientContext(site_url, auth_ctx)
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web Title:", web.properties["Title"])
else:
raise ValueError(“Failed to acquire token for the given client credentials.”)
It errors out at ctx.execute_query() with the following error message
ValueError: {“error”:“invalid_request”,“error_description”:"AADSTS900023: Specified tenant identifier ‘none’ is neither a valid DNS name, nor a valid external domain.
Is there a way to trouble shoot the cause of this error, since the error message is not very informative?
Hi @david.makovoz
Thank you for your post and welcome the Matillion Community!
Thanks for your post, I spoke with a member of our team about this and it seems there has been some Miscoding from the Azure Portal and the tenent_id has not been added to the request.
Checking that and getting added should resolve this issue. If you have any further questions, please let me know.
Kind regards, Joe
tenant_id is included here:
authority_url = “https://login.microsoftonline.us/<tenant_id>”
Where else should it be included?
1 Like
Thanks for that @david.makovoz
We have had a look and Either the value was not correctly formatted or the value is incorrect that is the error that you are getting back from the SDK anything past suggests that you would need to contact your Azure admin/support team.
authority_url = “https://login.microsoftonline.us/<tenant_id>” looks as if its the placeholder for this and should be a more unique URL.
Kind regards, Joe
I didn’t want to place the real tenant_id in the question. Obviously in my code I used the real tenant_id string instead of <tenant_id> placeholder
Ah, thanks for clearing that up @david.makovoz It does still suggest a potential issue with that and the advice to speak with your Azure admin would be best at this point.
Kind regards, Joe