- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi guys,
Need help. I am trying to create a custom python script with has a dependecy on office365 (https://github.com/vgrem/Office365-REST-Python-Client) module. The script was creating REST API calls to SharePoint to update, delete, add items to it. I am using client ID and client secret as Credentials to access SharePoint. The script will be triggered by a Scheduled Search.
I placed the file on $SPLUNK_HOME/etc/apps/<appname>/bin/
both the script and the office365 folder.
When I try to run the script using python scriptName.py
on that directory, It is working fine so I expected that It will work the same when the script was triggered from Splunk. But no. I am getting authentication error.
Traceback (most recent call last):
File "sharepoint_fetch_data.py", line 100, in <module>
print ("ingestion error: {0}".format(ctx_auth.get_last_error()))
File "/opt/splunk/etc/apps/sharepoint_connector/bin/office365/runtime/auth/authentication_context.py", line 37, in get_last_error
return self.provider.get_last_error()
AttributeError: 'ACSTokenProvider' object has no attribute 'get_last_error'
Which I am not getting when I run It using python scriptName.py
only.
I also tried to run the script using $SPLUNK_HOME/bin/splunk cmd python scriptName.py
and the errors were the same. It seems that I am getting the error when running it with Splunk's python. Like blocking the connection or something... I don't know.
Did I missed to do or configure something ? Please help me. Thanks in advance!!
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @darljed,
It seems like the Splunk Python could be missing some of the functions used by that script. Try updating your script to make it use the system's python :
https://stackoverflow.com/questions/3108285/in-python-script-how-do-i-set-pythonpath
This should solve your problem.
PS: This could also be because you're running the script as root and Splunk is running it as the Splunk user ?
Cheers,
David
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I got the fix now 🙂
https://answers.splunk.com/answers/2821/python-scripted-inputs-run-with-the-wrong-version-of-python-...
So I just need to create a shell script to trigger my python script.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @darljed,
It seems like the Splunk Python could be missing some of the functions used by that script. Try updating your script to make it use the system's python :
https://stackoverflow.com/questions/3108285/in-python-script-how-do-i-set-pythonpath
This should solve your problem.
PS: This could also be because you're running the script as root and Splunk is running it as the Splunk user ?
Cheers,
David
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I guess you're right about Splunk's python could be missing something... I also tried setting up sys.path
but still it will use Splunk's Python.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thanks Anyway 🙂
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

You're welcome. I also checked the git repository you linked. It seems that get_last_error
is in office365/runtime/auth/authentication_context.py
did you grab the entire repository or just the files you need ? Could be a good idea to import the whole thing and try it out with all the code there.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yes, I downloaded Everything and Imported the needed resources. It was actually working when running outside Splunk so It means that there are no problem with the package.
But luckily, I got the fix now 🙂
I just need to create a shell script to trigger my python script from outside Splunk's Python..
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Awesome ! 🙂
