Giter VIP home page Giter VIP logo

Comments (7)

v-chojas avatar v-chojas commented on July 18, 2024

If you're using the msodbcsql (17 or 18) driver you can give it the access token directly: https://learn.microsoft.com/en-us/sql/connect/odbc/using-azure-active-directory#authenticating-with-an-access-token

from pyodbc.

gordthompson avatar gordthompson commented on July 18, 2024

Hey @v-chojas - Would this be the same issue as documented in the wiki here

https://github.com/mkleehammer/pyodbc/wiki/Tips-and-Tricks-by-Database-Platform#authenticate-using-an-access-token-from-azure-active-directory

making this a duplicate of #228 ?

from pyodbc.

v-chojas avatar v-chojas commented on July 18, 2024

@gordthompson I wouldn't call this a duplicate without knowing more details about what the OP is trying to accomplish ("federated credentials" is vague and can refer to various things) or indeed if this is the msodbcsql driver being used.

from pyodbc.

kachely26 avatar kachely26 commented on July 18, 2024

Thank you so much @v-chojas and @gordthompson!
I think this is what I want https://github.com/mkleehammer/pyodbc/wiki/Tips-and-Tricks-by-Database-Platform#authenticate-using-an-access-token-from-azure-active-directory
Besides, when I use access token, should I set the connection as something like below?
Driver={ODBC Driver 18 for SQL Server};Server={server};Authentication=ActiveDirectoryIntegrated;Encrypt=yes;?
Which Authentication type should I use for access token authentication?
Should I set the token when calling connect function? Is it possible to set it in the connection string?
conn = pyodbc.connect(connstr, attrs_before = { 1256:bytearray(tokenstruct) })

from pyodbc.

v-chojas avatar v-chojas commented on July 18, 2024

Do not specify authentication mode when using access token.
https://learn.microsoft.com/en-us/sql/connect/odbc/using-azure-active-directory?view=sql-server-ver16#authenticating-with-an-access-token

from pyodbc.

kachely26 avatar kachely26 commented on July 18, 2024

I got the access token from

https://review.learn.microsoft.com/en-us/identity/microsoft-identity-platform/federated-identity-credentials?branch=main&tabs=python#msal-python

Does the access token a correct one?

I see it returns me Login failed for user \'<token-identified principal>\'. The server is not currently configured to accept this token. (18456) (SQLDriverConnect)")\n(Background on this error at: http://sqlalche.me/e/13/rvf5)

Could you provide some insights here?

from pyodbc.

v-chojas avatar v-chojas commented on July 18, 2024

You need to add the corresponding account on the server with CREATE USER ... FROM EXTERNAL PROVIDER

from pyodbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.