@@ -134,16 +134,18 @@ TokenLoop:
134
134
continue
135
135
} else if errors .Is (verificationErr , ErrTokenExpired ) {
136
136
continue TokenLoop
137
+ } else {
138
+ // Received an unexpected/unhandled error type.
139
+ r = createResult (token , clientId , tenantId , isVerified , extraData , verificationErr )
140
+ break ClientLoop
137
141
}
138
142
}
139
143
140
144
// The result is verified or there's only one associated client and tenant.
141
145
if isVerified {
142
- r = createResult (tenantId , clientId , token , isVerified , extraData , verificationErr )
146
+ r = createResult (token , clientId , tenantId , isVerified , extraData , verificationErr )
143
147
break ClientLoop
144
148
}
145
-
146
- // The result may be valid for another client/tenant.
147
149
}
148
150
}
149
151
}
@@ -244,17 +246,20 @@ func verifyMatch(ctx context.Context, client *http.Client, refreshToken string,
244
246
// https://login.microsoftonline.com/error?code=9002313
245
247
d := errResp .Description
246
248
switch {
247
- case strings .HasPrefix (d , "AADSTS70008:" ), strings .HasPrefix (d , "AADSTS700082:" ):
249
+ case strings .HasPrefix (d , "AADSTS70008:" ),
250
+ strings .HasPrefix (d , "AADSTS700082:" ),
251
+ strings .HasPrefix (d , "AADSTS70043:" ):
248
252
// https://login.microsoftonline.com/error?code=70008
249
253
// https://login.microsoftonline.com/error?code=700082
254
+ // https://login.microsoftonline.com/error?code=70043
250
255
return false , nil , ErrTokenExpired
251
256
case strings .HasPrefix (d , "AADSTS700016:" ):
252
257
// https://login.microsoftonline.com/error?code=700016
253
258
return false , nil , ErrClientNotFoundInTenant
254
259
case strings .HasPrefix (d , "AADSTS90002:" ):
255
260
// https://login.microsoftonline.com/error?code=90002
256
261
return false , nil , ErrTenantNotFound
257
- case strings .HasPrefix (d , "AADSTS9002313" ):
262
+ case strings .HasPrefix (d , "AADSTS9002313: " ):
258
263
// This seems to be a generic "invalid token" error code.
259
264
// 'invalid_grant': AADSTS9002313: Invalid request. Request is malformed or invalid.
260
265
return false , nil , nil
0 commit comments