MCPcopy
hub / github.com/codeaashu/claude-code / fetchAndStoreUserRoles

Function fetchAndStoreUserRoles

src/services/oauth/client.ts:276–309  ·  view source on GitHub ↗
(
  accessToken: string,
)

Source from the content-addressed store, hash-verified

274}
275
276export async function fetchAndStoreUserRoles(
277 accessToken: string,
278): Promise<void> {
279 const response = await axios.get(getOauthConfig().ROLES_URL, {
280 headers: { Authorization: `Bearer ${accessToken}` },
281 })
282
283 if (response.status !== 200) {
284 throw new Error(`Failed to fetch user roles: ${response.statusText}`)
285 }
286 const data = response.data as UserRolesResponse
287 const config = getGlobalConfig()
288
289 if (!config.oauthAccount) {
290 throw new Error('OAuth account information not found in config')
291 }
292
293 saveGlobalConfig(current => ({
294 ...current,
295 oauthAccount: current.oauthAccount
296 ? {
297 ...current.oauthAccount,
298 organizationRole: data.organization_role,
299 workspaceRole: data.workspace_role,
300 organizationName: data.organization_name,
301 }
302 : current.oauthAccount,
303 }))
304
305 logEvent('tengu_oauth_roles_stored', {
306 org_role:
307 data.organization_role as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
308 })
309}
310
311export async function createAndStoreApiKey(
312 accessToken: string,

Callers 1

installOAuthTokensFunction · 0.85

Calls 5

getOauthConfigFunction · 0.85
getGlobalConfigFunction · 0.85
saveGlobalConfigFunction · 0.85
logEventFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected