Blog Post

Azure Database Support Blog
2 MIN READ

Investigating Issue "Security token could not be authenticated" After Upgrading to Latest Tedious.

sakshigupta's avatar
sakshigupta
Icon for Microsoft rankMicrosoft
Aug 03, 2023

Today I encountered an issue when customers upgraded their old version of tedious to the latest 16.X.X and started having connectivity issues using Active Directory Password Based Authentication. However, when they used the older version of tedious (11.X.X), there were no issues.

When I debugged the code using Visual Studio Code, I got an error message saying “Requests can only be made in the LoggedIn state, not the SentLogin7Withfedauth state, which could be a consequence of the first one: Security token could not be authenticated or authorized.”

 

I was able to reproduce the issue on my local, and I validated if any additional parameters or configurations were needed when upgrading to the latest version. I also checked the latest release changes with all versions and observed that version v15.0.0 has some breaking changes.

 

Release v14.2.0 · tediousjs/tedious · GitHub

 

 

 

 

 

 

I noticed that the clientId is required as part of the connection string and should have a few permissions as a minimum to connect.

 

  1. Public Client Flow should be enabled.
  2. the user impersonation permission should be granted.

 

Just to clear here, these permissions are required for the clientId. To provide these permissions to the clientId, Please follow the below steps:-

 

  • Search for Active Directory from the Azure portal, -> App Registration and search for the app you have created and trying to leverage for connectivity.
  • Ensure to provide below permissions.

 

Public Client Flow should be enabled.

 

 

2. Grant user impersonation permission.

 

 

 

I ensured to provide the necessary permissions. After that, I was able to connect to the database from the application. I'd like to thank my colleague Matt Hyon for helping me out here. Happy learning!

 

 

Happy Learning!!

 

 

 

 

 

 

 

 

 

Published Aug 03, 2023
Version 1.0
No CommentsBe the first to comment