@@ -11,15 +11,7 @@ import { InlineCompletionManager } from '../app/inline/completion'
11
11
import { AmazonQLspAuth , encryptionKey , notificationTypes } from './auth'
12
12
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
13
13
import { 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'
23
15
import { activate } from './chat/activation'
24
16
import { AmazonQResourcePaths } from './lspInstaller'
25
17
@@ -109,7 +101,7 @@ export async function startLanguageServer(
109
101
} ,
110
102
}
111
103
} )
112
- await auth . init ( )
104
+ await auth . refreshConnection ( )
113
105
114
106
if ( Experiments . instance . get ( 'amazonqLSPInline' , false ) ) {
115
107
const inlineManager = new InlineCompletionManager ( client )
@@ -129,23 +121,16 @@ export async function startLanguageServer(
129
121
activate ( client , encryptionKey , resourcePaths . ui )
130
122
}
131
123
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 ( )
141
125
142
126
toDispose . push (
143
127
AuthUtil . instance . auth . onDidChangeActiveConnection ( async ( ) => {
144
- await auth . init ( )
128
+ await auth . refreshConnection ( )
145
129
} ) ,
146
130
AuthUtil . instance . auth . onDidDeleteConnection ( async ( ) => {
147
131
client . sendNotification ( notificationTypes . deleteBearerToken . method )
148
- } )
132
+ } ) ,
133
+ { dispose : ( ) => clearInterval ( refreshInterval ) }
149
134
)
150
135
} )
151
136
}
0 commit comments