@@ -11,15 +11,7 @@ import { InlineCompletionManager } from '../app/inline/completion'
1111import { AmazonQLspAuth , encryptionKey , notificationTypes } from './auth'
1212import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1313import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
14- import {
15- Settings ,
16- oidcClientName ,
17- createServerOptions ,
18- globals ,
19- Experiments ,
20- getLogger ,
21- Commands ,
22- } from 'aws-core-vscode/shared'
14+ import { Settings , oidcClientName , createServerOptions , globals , Experiments , Commands } from 'aws-core-vscode/shared'
2315import { activate } from './chat/activation'
2416import { AmazonQResourcePaths } from './lspInstaller'
2517
@@ -109,7 +101,7 @@ export async function startLanguageServer(
109101 } ,
110102 }
111103 } )
112- await auth . init ( )
104+ await auth . refreshConnection ( )
113105
114106 if ( Experiments . instance . get ( 'amazonqLSPInline' , false ) ) {
115107 const inlineManager = new InlineCompletionManager ( client )
@@ -129,23 +121,16 @@ export async function startLanguageServer(
129121 activate ( client , encryptionKey , resourcePaths . ui )
130122 }
131123
132- // Temporary code for pen test. Will be removed when we switch to the real flare auth
133- const authInterval = setInterval ( async ( ) => {
134- try {
135- await auth . init ( )
136- } catch ( e ) {
137- getLogger ( 'amazonqLsp' ) . error ( 'Unable to update bearer token: %s' , ( e as Error ) . message )
138- clearInterval ( authInterval )
139- }
140- } , 300000 ) // every 5 minutes
124+ const refreshInterval = auth . startTokenRefreshInterval ( )
141125
142126 toDispose . push (
143127 AuthUtil . instance . auth . onDidChangeActiveConnection ( async ( ) => {
144- await auth . init ( )
128+ await auth . refreshConnection ( )
145129 } ) ,
146130 AuthUtil . instance . auth . onDidDeleteConnection ( async ( ) => {
147131 client . sendNotification ( notificationTypes . deleteBearerToken . method )
148- } )
132+ } ) ,
133+ { dispose : ( ) => clearInterval ( refreshInterval ) }
149134 )
150135 } )
151136}
0 commit comments