Skip to content

Commit

Permalink
filter OAuth credentials in dropdown by required scopes for block
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed Sep 20, 2024
1 parent e213de6 commit 34a3dd9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions autogpt_platform/frontend/src/hooks/useCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

0 comments on commit 34a3dd9

Please sign in to comment.