Skip to content

Commit 2dfbb9a

Browse files
Merge pull request #230 from gleanwork/codex/hjdivad/fix-getoauthscopes-to-include-offline_access
Fix Azure OAuth support
2 parents a88feca + bbf7269 commit 2dfbb9a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/mcp-server-utils/src/auth/auth.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,13 @@ async function pollForToken(
691691
/**
692692
* Returns the OAuth scopes we need for the issuer.
693693
*
694-
* This will always include "openid profile" but some providers may need other
695-
* scopes to make the user email available. We require the user email for the
696-
* token to be valid.
694+
* In general this is "openid profile offline_access", but some providers may
695+
* require different scopes for idiosyncratic reasons.
696+
*
697+
* We require two things that are driven by scopes:
698+
*
699+
* - user email (openid profile)
700+
* - refresh tokens (offline_access)
697701
*/
698702
export function getOAuthScopes(config: GleanOAuthConfig): string {
699703
const { issuer: issuer } = config;
@@ -707,7 +711,7 @@ export function getOAuthScopes(config: GleanOAuthConfig): string {
707711
case 'okta.com':
708712
return 'openid profile offline_access';
709713
default:
710-
return 'openid profile';
714+
return 'openid profile offline_access';
711715
}
712716
}
713717

packages/mcp-server-utils/src/test/auth/auth.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,9 @@ describe('auth', () => {
658658
authType: 'oauth' as const,
659659
baseUrl: 'https://api.example.com',
660660
};
661-
expect(getOAuthScopes(config)).toMatchInlineSnapshot(`"openid profile"`);
661+
expect(getOAuthScopes(config)).toMatchInlineSnapshot(
662+
`"openid profile offline_access"`,
663+
);
662664
});
663665
});
664666

0 commit comments

Comments
 (0)