@@ -83,9 +83,11 @@ export class CallbackWorkflow implements Workflow {
83
83
) ;
84
84
let result ;
85
85
if ( entry ) {
86
+ console . log ( 'ENTRY IN THE CACHE' ) ;
86
87
// Reauthentication cannot use a token from the cache since the server has
87
88
// stated it is invalid by the request for reauthentication.
88
89
if ( entry . isValid ( ) && ! reauthenticating ) {
90
+ console . log ( 'ENTRY VALID NO REAUTH' ) ;
89
91
// Presence of a valid cache entry means we can skip to the finishing step.
90
92
result = await this . finishAuthentication (
91
93
connection ,
@@ -94,6 +96,7 @@ export class CallbackWorkflow implements Workflow {
94
96
response ?. speculativeAuthenticate ?. conversationId
95
97
) ;
96
98
} else {
99
+ console . log ( 'FETCH ACCESS TOKEN' ) ;
97
100
// Presence of an expired cache entry means we must fetch a new one and
98
101
// then execute the final step.
99
102
const tokenResult = await this . fetchAccessToken (
@@ -105,13 +108,15 @@ export class CallbackWorkflow implements Workflow {
105
108
refreshCallback
106
109
) ;
107
110
try {
111
+ console . log ( 'FINISH AUTH' ) ;
108
112
result = await this . finishAuthentication (
109
113
connection ,
110
114
credentials ,
111
115
tokenResult ,
112
116
reauthenticating ? undefined : response ?. speculativeAuthenticate ?. conversationId
113
117
) ;
114
118
} catch ( error ) {
119
+ console . log ( 'ERROR ON AUTH FINISH' ) ;
115
120
// If we are reauthenticating and this errors with reauthentication
116
121
// required, we need to do the entire process over again and clear
117
122
// the cache entry.
@@ -133,6 +138,7 @@ export class CallbackWorkflow implements Workflow {
133
138
}
134
139
}
135
140
} else {
141
+ console . log ( 'NO CACHE ENTRY' ) ;
136
142
// No entry in the cache requires us to do all authentication steps
137
143
// from start to finish, including getting a fresh token for the cache.
138
144
const startDocument = await this . startAuthentication (
@@ -227,6 +233,7 @@ export class CallbackWorkflow implements Workflow {
227
233
if ( entry ) {
228
234
// If the cache entry is valid, return the token result.
229
235
if ( entry . isValid ( ) && ! reauthenticating ) {
236
+ console . log ( 'FETCH - ENTRY VALID NO REAUTH' ) ;
230
237
return entry . tokenResult ;
231
238
}
232
239
// If the cache entry is not valid, remove it from the cache and first attempt
@@ -254,6 +261,7 @@ export class CallbackWorkflow implements Workflow {
254
261
) ;
255
262
throw new MongoMissingCredentialsError ( CALLBACK_RESULT_ERROR ) ;
256
263
}
264
+ console . log ( 'DELETING EXPIRED ENTRIES' ) ;
257
265
// Cleanup the cache.
258
266
this . cache . deleteExpiredEntries ( ) ;
259
267
// Put the new entry into the cache.
0 commit comments