question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DefaultAzureCredential Azure SQL error: VisualStudioCodeCredential The refresh token has expired due to inactivity

See original GitHub issue
  • Package Name: azure-identity
  • Package Version: 1.8.0
  • Operating System: Windows
  • Python Version: 3.9.7

Describe the bug Using DefaultAzureCredential from azure.identity while get_token() gives the following error for certain users: VisualStudioCodeCredential The refresh token has expired due to inactivity

To Reproduce Using the following code: https://docs.sqlalchemy.org/en/14/dialects/mssql.html#connecting-to-databases-with-access-tokens On this line:

raw_token = azure_credentials.get_token(TOKEN_URL).token.encode("utf-16-le")

the error is thrown that the refresh token has expired due to inactivity of greater than 90 days. The code works fine for me, but not for my coworkers. We’ve tried updating all packages and dropping the users from Azure SQL and recreating them. I found this in the documentation (https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) saying

As of August 2018 this token is revoked after 90 days of inactivity, but this value can be changed by Microsoft or your tenant administrator. Once the token is revoked you get a message from the CLI saying you need to login again.

However, I can’t find anywhere in the Azure Portal to renew the token. Also, using DefaultAzureCredential works fine for connecting to blob storage, the error only throws on get_token() on the database.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
xiangyan99commented, May 5, 2022
1reaction
kashifkhancommented, Mar 24, 2022

Hi @blawrence-datadx , thanks for the feedback. We’ll take a look at this and get back to you asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The refresh token has expired due to inactivity - Stack Overflow
VisualStudioCodeCredential : Azure Active Directory error '(invalid_grant) AADSTS700082: The refresh token has expired due to inactivity. So I ...
Read more >
Solved: OAuth Refresh token has expired after 90 days
The oauth token expires after 90 days and we have to login to the Office365 POP mailbox from Rightfax and renew the token....
Read more >
Azure AD refresh token is getting invalid frequently
This error is due to when refresh token can be expired due to either if the password changed for the user or the...
Read more >
azure-identity - PyPI
Excluded VisualStudioCodeCredential from DefaultAzureCredential token chain by default as SDK authentication via Visual Studio Code is broken due to issue # ...
Read more >
Refresh Token Expired - Microsoft Power BI Community
Hi all, we have several datasets in PBI workspace connected to same Azure Analysis Service server, using OAuth2 authentication and Organizational.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found