MCPcopy Index your code
hub / github.com/simstudioai/sim / toCredentialResponse

Function toCredentialResponse

apps/sim/app/api/auth/oauth/credentials/route.ts:24–51  ·  view source on GitHub ↗
(
  id: string,
  displayName: string,
  providerId: string,
  updatedAt: Date,
  scope: string | null,
  credentialType: 'oauth' | 'service_account' = 'oauth'
)

Source from the content-addressed store, hash-verified

22const logger = createLogger('OAuthCredentialsAPI')
23
24function toCredentialResponse(
25 id: string,
26 displayName: string,
27 providerId: string,
28 updatedAt: Date,
29 scope: string | null,
30 credentialType: 'oauth' | 'service_account' = 'oauth'
31) {
32 const storedScope = scope?.trim()
33 // Some providers (e.g. Box) don't return scopes in their token response,
34 // so the DB column stays empty. Fall back to the configured scopes for
35 // the provider so the credential-selector doesn't show a false
36 // "Additional permissions required" banner.
37 const scopes = storedScope
38 ? storedScope.split(/[\s,]+/).filter(Boolean)
39 : getCanonicalScopesForProvider(providerId)
40 const [_, featureType = 'default'] = providerId.split('-')
41
42 return {
43 id,
44 name: displayName,
45 provider: providerId,
46 type: credentialType,
47 lastUsed: updatedAt.toISOString(),
48 isDefault: featureType === 'default',
49 scopes,
50 }
51}
52
53/**
54 * Get credentials for a specific provider

Callers 1

route.tsFile · 0.85

Calls 1

Tested by

no test coverage detected