Run Python Script from Service Now Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2019 10:45 AM
Hello,
I have developed python script to create users in DUO application for assigning them DUO token.
As per DUO documentation, we can consume DUO REST API only via python, perl or ruby clients. Service now can not consume DUO REST API directly due to security constraints.
I need to consume this python script from service now workflow.
What is the best way to call python script from service now platform?
Regards,
Sachin
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2019 05:06 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2019 09:02 PM
I tried to consume DUO REST API directly from service now and I was not successful.
When i contacted DUO support, they said that i need to write middleware script ( e.g python, ruby, perl etc) to consume DUO REST API since DUO REST expects HMAC signature for consuming their API.
Normal User name and password combination authentication doesn't work with DUO REST API.Hence, i was forced to develop python script to consume DUO REST API.
Can you give example code in service now to consume DUO REST API?
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2019 04:03 PM
I tend to agree with Dhravesh, if you can get it done directly using the API, your solution will be more scalable and maintainable than the Python Orchestration method. I would sincerely doubt the user cannot be created directly calling from servicenow.
ServiceNow support custom outbound REST messages where you can customize the parameters sent, if the normal auth doesn't work, and also you can call it via RESTMessageV2 from a workflow script.
https://docs.servicenow.com/bundle/london-application-development/page/integrate/outbound-rest/concept/c_OutboundRESTWebService.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2024 11:52 PM
@TylerTeter I'm using the following script to access Cisco Duo Rest API. But i'm getting following error. Your valuable inputs would be appreciated.
Response body: {"code": 40102, "message": "Invalid identity in request credentials", "stat": "FAIL"}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 12:55 AM
This thread takes me back - lots of things have changed with the introduction of Flow Designer since 2019.
Based on your error code of 401, it's typically a credential issue, or it's an issue of your calling location. If you need to call this from through the MID server using RestMessageV2 you can use the setMIDServer("name") method.
Have you been able to validate if the API works another way? Like in postman or powershell or something? That call help you verify your authorization header is correct.
Finally, you can enable REST debug logging and look in the HTTP outbound logs for more verbose error information also.
Cheers!