diff --git a/autogpt_platform/frontend/src/hooks/useCredentials.ts b/autogpt_platform/frontend/src/hooks/useCredentials.ts index 2072b83da204..ac0720d6cd13 100644 --- a/autogpt_platform/frontend/src/hooks/useCredentials.ts +++ b/autogpt_platform/frontend/src/hooks/useCredentials.ts @@ -58,11 +58,20 @@ export default function useCredentials(): CredentialsData | null { }; } + // Filter by OAuth credentials that have sufficient scopes for this block + const requiredScopes = credentialsSchema.credentials_scopes; + const savedOAuthCredentials = requiredScopes + ? provider.savedOAuthCredentials.filter((c) => + new Set(c.scopes).isSupersetOf(new Set(requiredScopes)), + ) + : provider.savedOAuthCredentials; + return { ...provider, schema: credentialsSchema, supportsApiKey, supportsOAuth2, + savedOAuthCredentials, isLoading: false, }; }