Getting Data In

call not properly authenticated

NatanS
Loves-to-Learn

Response Code: 401
Response text: <?xml version="1.0" encoding="UTF-8"?>
<response>
<messages>
<msg type="WARN">call not properly authenticated</msg>
</messages>
</response>

I am using Splunk bearer token in my python program using REST API, but suddenly I got this error also I have another precisely program that using Splunk token and it works fine without get the error that I got from the other program.  I already test the token it gets 200 responses. I don't know what happens. 

Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Well. 401 does mean that the authentication was not performed correctly (which means no token provided or wrong token).

So I'd start by checking what requests are being sent to Splunk from your both scripts (the one working properly and the one not working) and comparing the requests (especially the tokens of course).

0 Karma

NatanS
Loves-to-Learn

../python3.9/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host ''. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
Response Code: 401
Response Text: <?xml version="1.0" encoding="UTF-8"?>
<response>
<messages>
<msg type="WARN">call not properly authenticated</msg>
</messages>
</response>


This is the error from splunk that I got using the token that I made. Its 100% correct token from splunk. Is this because of the ssl ?

0 Karma

PickleRick
SplunkTrust
SplunkTrust

These are two separate issues.

One is that you're doing a call to https endpoint without verifying server's certificate. That's not a very secure thing to do (especially that you're authenticating yourself against some unverified party) so you're getting a warning from the script.

Another thing is that you're not properly authenticating to the server. That' why you're getting an error response from the server.

0 Karma

NatanS
Loves-to-Learn

So, what should I do in my program? Do I need to add the ssl certificate? Also how to know properly authenticating to the server? Can I ask for your help about these matters?

Thank you for your attention to this matter, I am waiting for your response

0 Karma

PickleRick
SplunkTrust
SplunkTrust

As I said - while the connection might be working without properly authenticating the server (verifying server's certificate) the proper way of working with TLS-protected connection is to make sure the server is who it claims it is. So you should make sure your python app can properly verify the server's certificate - the server's cert should be issued by CA that your python code trusts. And that is one thing but it's just a general security-related thing not directly causing the server to return 401.

401 means you're not providing correct authentication data. As I said before - if supposedly the same token works with another host or app comparw the requests made by tue working app and the non-working app and check what is different. We can't know what's wrong as so far the only thing we have is "the server says 401".

0 Karma

NatanS
Loves-to-Learn

This is the error message from splunk server
ERROR UserManagerPro [727840 TcpChannelThread] - Requesting user info through AQR returned an error Error in Attribute query request, AttributeQueryTransaction err=No error, AttributeQueryTransaction descr=Method Not Allowed, AttributeQueryTransaction statusCode=405 for user: .........

This is from access log (http) 401:
"GET /services/authentication/current-context HTTP/1.1" 401 148 "-" "python-requests/2.31.0" - - - 19ms

And the audit log it said not valid
user=n/a, action=validate_token, info=JsonWebToken validation failed

Tags (1)
0 Karma

marnall
Motivator

Perhaps your API request is malformed. Has your python program ever got the desired response, perhaps with another token?

If not, you could post a sanitized version of the segment of your python script that sends the API request, so we can see if there is something wrong.

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...