mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.95k stars 563 forks source link

How to surface azure active directory service principal related errors #1365

Closed prdpsvs closed 5 months ago

prdpsvs commented 5 months ago

Environment

Issue

I am using Azure Service Principal Authentication with pyodbc. what is the best way to surface issue when user provides incorrect client id or secret. Right now, any error during connection is throwing ('HYT00', '[HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

I tried to capture errors from azure identity SDK using from azure.core.exceptions import ClientAuthenticationError, HttpResponseError but no luck. Any thoughts?

v-chojas commented 5 months ago

The driver returns several diag recs; do you see those in the ODBC trace?

prdpsvs commented 5 months ago

I would like to capture these at the connection failure time programmatically and appropriately surface user-friendly messages. Any specific options to figure out?

v-chojas commented 5 months ago

I am asking if you see all the diag recs in the ODBC trace.