Grammarly Enterprise RBAC
Overview
Manage Grammarly enterprise access with OAuth scopes and organization-level API credentials.
OAuth Scopes
| Scope | Access |
|-------|--------|
| scores-api:read | Read writing scores |
| scores-api:write | Submit text for scoring |
| ai-detection:read | Read AI detection results |
| plagiarism:read | Read plagiarism results |
Instructions
Step 1: Separate Credentials Per Team
const teamClients = {
content: new GrammarlyClient(process.env.GRAMMARLY_CONTENT_ID!, process.env.GRAMMARLY_CONTENT_SECRET!),
marketing: new GrammarlyClient(process.env.GRAMMARLY_MARKETING_ID!, process.env.GRAMMARLY_MARKETING_SECRET!),
};
Step 2: Scope-Based Access
function canUseAPI(team: string, api: 'score' | 'ai' | 'plagiarism'): boolean {
const permissions: Record<string, string[]> = {
content: ['score', 'ai', 'plagiarism'],
marketing: ['score'],
engineering: ['score', 'ai'],
};
return permissions[team]?.includes(api) ?? false;
}