MCPcopy Create free account
hub / github.com/freecodexyz/free-code / fetchProfileInfo

Function fetchProfileInfo

src/services/oauth/client.ts:383–448  ·  view source on GitHub ↗
(accessToken: string)

Source from the content-addressed store, hash-verified

381}
382
383export async function fetchProfileInfo(accessToken: string): Promise<{
384 subscriptionType: SubscriptionType | null
385 displayName?: string
386 rateLimitTier: RateLimitTier | null
387 hasExtraUsageEnabled: boolean | null
388 billingType: BillingType | null
389 accountCreatedAt?: string
390 subscriptionCreatedAt?: string
391 rawProfile?: OAuthProfileResponse
392}> {
393 const profile = await getOauthProfileFromOauthToken(accessToken)
394 const orgType = profile?.organization?.organization_type
395
396 // Reuse the logic from fetchSubscriptionType
397 let subscriptionType: SubscriptionType | null = null
398 switch (orgType) {
399 case 'claude_max':
400 subscriptionType = 'max'
401 break
402 case 'claude_pro':
403 subscriptionType = 'pro'
404 break
405 case 'claude_enterprise':
406 subscriptionType = 'enterprise'
407 break
408 case 'claude_team':
409 subscriptionType = 'team'
410 break
411 default:
412 // Return null for unknown organization types
413 subscriptionType = null
414 break
415 }
416
417 const result: {
418 subscriptionType: SubscriptionType | null
419 displayName?: string
420 rateLimitTier: RateLimitTier | null
421 hasExtraUsageEnabled: boolean | null
422 billingType: BillingType | null
423 accountCreatedAt?: string
424 subscriptionCreatedAt?: string
425 } = {
426 subscriptionType,
427 rateLimitTier: profile?.organization?.rate_limit_tier ?? null,
428 hasExtraUsageEnabled:
429 profile?.organization?.has_extra_usage_enabled ?? null,
430 billingType: profile?.organization?.billing_type ?? null,
431 }
432
433 if (profile?.account?.display_name) {
434 result.displayName = profile.account.display_name
435 }
436
437 if (profile?.account?.created_at) {
438 result.accountCreatedAt = profile.account.created_at
439 }
440

Callers 1

refreshOAuthTokenFunction · 0.85

Calls 2

logEventFunction · 0.85

Tested by

no test coverage detected