none
Unable to obtain correct token for authentication Azure SQL db using windows authentication RRS feed

  • Question

  • I am trying to authenticate user for Azure SQL db access using windows authentication with token generation. I have followed the approach specified in blogs. Below is the code snippet.

        var conn = (SqlConnection)this.Database.GetDbConnection();
        conn.AccessToken = (new AzureServiceTokenProvider()).GetAccessTokenAsync("https://database.windows.net/").Result;

    The problem I am facing is in the token generation. The token does get generated but authentication fails. When I tried to decode the token, it shows wrong user account. Instead of taking my corporate email, it was taking one of my personal email id. I looked everywhere but couldn't find a solution to pass username.
    Wednesday, July 24, 2019 6:42 PM

All replies

  • Hi bestrachit,

    Thank you for posting here.

    Since this thread is related to Azure SQL Database, I suggest that you could post in Azure SQL Database forum.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 25, 2019 2:44 AM