VSCode Extension Issues

Product: PowerShell Universal
Version: 1.5.0

Previously had PSU 1.4.6 installed (was installed automatically by the VS Code extension). Downloaded and ran the 1.5.0 MSI installer. Since then, the VS Code extension will not allow any config file changes and refreshing does not show any scripts, APIs, Dashboards, etc. (which is kind of the whole point of the extension). I’ve tried uninstalling/reinstalling the extension as well as PSU to no avail. Trying to open a file under “Configuration” gives the following error:

“Error running command powershell-universal.openConfigFile: undefined. This is likely caused by the extension that contributes powershell-universal.openConfigFile.”

Can you try to generate a new app token?

Generate it in the admin console.

Set it in the settings of the extension.

I just tried myself and was able to connect to a 1.5 instance and open config files.

Generated a new app token and entered into the extension settings. Still the same error (tried before and after restarting VS Code). I even get an error message just by clicking the “Refresh” icon for the Configuration section of the extension “Failed to refresh configuration.”

I would suggest looking in the PowerShell Universal log in %ProgramData%\PowerShellUniversal. It seems that the web server is throwing an error.

Error below is in that log file when trying to use the extension:

2020-11-22T10:23:31.4068628-07:00 0HM4EVU08I94S:00000001 [INF] Failed to validate the token. (616bef97)
Microsoft.IdentityModel.Tokens.SecurityTokenNoExpirationException: IDX10225: Lifetime validation failed. The token is missing an Expiration Time. Tokentype: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'.
   at Microsoft.IdentityModel.Tokens.Validators.ValidateLifetime(Nullable`1 notBefore, Nullable`1 expires, SecurityToken securityToken, TokenValidationParameters validationParameters)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateLifetime(Nullable`1 notBefore, Nullable`1 expires, JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)
   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
2020-11-22T10:23:31.4068968-07:00 0HM4EVU08I94S:00000001 [INF] "Bearer" was not authenticated. Failure message: "IDX10225: Lifetime validation failed. The token is missing an Expiration Time. Tokentype: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'." (48071232)
2020-11-22T10:23:31.4069133-07:00 0HM4EVU08I94S:00000001 [INF] Authorization failed. (b15dd539)
2020-11-22T10:23:31.4069359-07:00 0HM4EVU08I94S:00000001 [INF] AuthenticationScheme: "Cookies" was challenged. (d45f1f38)
2020-11-22T10:23:31.4069487-07:00 0HM4EVU08I94S:00000001 [INF] AuthenticationScheme: "Bearer" was challenged. (d45f1f38)
2020-11-22T10:23:31.4076728-07:00 0HM4EVU08I94S:00000001 [INF] "Bearer" was not authenticated. Failure message: "IDX10225: Lifetime validation failed. The token is missing an Expiration Time. Tokentype: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'." (48071232)
2020-11-22T10:23:31.4076930-07:00 0HM4EVU08I94S:00000001 [INF] Authorization failed. (b15dd539)
2020-11-22T10:23:31.4077133-07:00 0HM4EVU08I94S:00000001 [INF] AuthenticationScheme: "Cookies" was challenged. (d45f1f38)
2020-11-22T10:23:31.4077250-07:00 0HM4EVU08I94S:00000001 [INF] AuthenticationScheme: "Bearer" was challenged. (d45f1f38)
2020-11-22T10:23:31.4077683-07:00 0HM4EVU08I94S:00000001 [INF] Request finished in 2.1545ms 401  (791a596a)

Newly created App Token this morning shows the below dates:
Created: Nov 22, 2020 9:28 AM
Expiration: Apr 8, 2048 9:28 AM

Sorry. I should have mentioned that we have an issue with tokens set to the Never lifetime. ASP.NET Core is rejecting them. Create a token with a lifetime of 1 year.

1 year expiration on the App Token fixed the issue! Maybe gray out / remove the “Never” option if it’s known to be broken. Appreciate the help!

1 Like

That’s the plan. We were hoping to figure out a way around it but we will probably just remove it in 1.5.3.