MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / getOrganizationUUID

Function getOrganizationUUID

src/services/oauth/client.ts:426–456  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

424 * @returns The organization UUID or null if not authenticated
425 */
426export async function getOrganizationUUID(): Promise<string | null> {
427 // Check global config first to avoid unnecessary API call
428 const globalConfig = getGlobalConfig()
429 const orgUUID = globalConfig.oauthAccount?.organizationUuid
430 if (orgUUID) {
431 return orgUUID
432 }
433
434 // Restored/dev builds may have token metadata populated without the full
435 // config write path. Prefer local token-derived values before making a
436 // profile request or giving up.
437 const cachedTokens = getClaudeAIOAuthTokens()
438 const tokenOrgUUID =
439 cachedTokens?.tokenAccount?.organizationUuid ??
440 cachedTokens?.profile?.organization?.uuid
441 if (tokenOrgUUID) {
442 return tokenOrgUUID
443 }
444
445 // Fall back to fetching from profile (requires user:profile scope)
446 const accessToken = cachedTokens?.accessToken
447 if (accessToken === undefined || !hasProfileScope()) {
448 return null
449 }
450 const profile = await getOauthProfileFromOauthToken(accessToken)
451 const profileOrgUUID = profile?.organization?.uuid
452 if (!profileOrgUUID) {
453 return null
454 }
455 return profileOrgUUID
456}
457
458/**
459 * Populate the OAuth account info if it has not already been cached in config.

Callers 15

callFunction · 0.85
pollRemoteSessionEventsFunction · 0.85
teleportToRemoteFunction · 0.85
archiveRemoteSessionFunction · 0.85
checkGithubAppInstalledFunction · 0.85
checkGithubTokenSyncedFunction · 0.85
fetchEnvironmentsFunction · 0.85
prepareApiRequestFunction · 0.85
createBridgeSessionFunction · 0.85
getBridgeSessionFunction · 0.85

Calls 3

getGlobalConfigFunction · 0.85
hasProfileScopeFunction · 0.50

Tested by

no test coverage detected