ident works by checking which system user is trying to connect, and allows it to connect with that as its criteria. Network can be added as a criteria as well.
A few points to guide on troubleshooting the issue:
- Are you 100% sure that the part that initiates the connection is running within the context of the user you want to authenticate as?
- Is the python client providing the same username?
- Is it running as a different user (through sudo, for example)?
- Are you running pgAdmin and the python client on the same host, so we can rule out other differences as a factor?
- Is the python client connecting to the same address as pgAdmin (External address vs. localhost address)?
Configuring Postgresql to use remote authentication based with md5/sha1 is probably the easiest way to reliably fix this. It will allow authentication by other users, if they know the password - but you should have control of who knows the password anyway.