microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.99k stars 29.53k forks source link

Expose access token expiration time from `AuthenticationSession` #152517

Open philliphoff opened 2 years ago

philliphoff commented 2 years ago

VS Code exposes the access token for an AuthenticationSession but not its expiration time. There are some client SDKs (notably one of Azure's SDKs) that expect a credentials object that exposes both the token and its expiration. (It happens, in the case of Azure, that faking an expiration time works, but that's an implementation detail that could easily break version to version.)

I propose adding an expiresAt property to AuthenticationSession:

declare namespace 'vscode' {
    export interface AuthenticationSession {
        /**
         * The date/time at which the access token will expire, expressed by the number of milliseconds elapsed since 1/1/1970 00:00:00 UTC.
         */
        readonly expiresAt: number;
    }
}
StephenWeatherford commented 2 weeks ago

This is required to create an Azure.Core.TokenCredential. We're having to make one up right now.