fix(mcp): coordinate OAuth token refresh and authorization polling
Prevent concurrent refresh-token rotation across instances, distinguish expired-but-refreshable tokens from active authorization, and bind OAuth popup polling to a per-attempt ID so stale tokens cannot satisfy new consent.
This commit is contained in:
@@ -2,6 +2,7 @@ package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -271,6 +272,10 @@ func isAuthorizationRequired(err error) bool {
|
||||
if mcpclient.IsOAuthAuthorizationRequiredError(err) || mcpclient.IsAuthorizationRequiredError(err) {
|
||||
return true
|
||||
}
|
||||
var reauth *mcp.OAuthReauthorizationRequiredError
|
||||
if errors.As(err, &reauth) {
|
||||
return true
|
||||
}
|
||||
msg := err.Error()
|
||||
return strings.Contains(msg, "authorization required") ||
|
||||
strings.Contains(msg, "no valid token") ||
|
||||
|
||||
Reference in New Issue
Block a user