MCPcopy Create free account
hub / github.com/ShipSecAI/studio / exchangeCode

Function exchangeCode

frontend/src/pages/IntegrationCallback.tsx:61–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59 let cancelled = false;
60
61 async function exchangeCode() {
62 try {
63 const connection = await api.integrations.completeOAuth(providerId, {
64 userId,
65 code: authCode,
66 state: authState,
67 redirectUri,
68 });
69
70 if (cancelled) {
71 return;
72 }
73
74 broadcastConnection(connection);
75 setStatus('success');
76 setMessage(`Connected to ${connection.providerName}. Redirecting…`);
77 setTimeout(() => {
78 const target = env.VITE_ENABLE_CONNECTIONS
79 ? `/integrations?connected=${connection.provider}`
80 : '/';
81 navigate(target, { replace: true });
82 }, 1200);
83 } catch (error) {
84 if (cancelled) {
85 return;
86 }
87 const description =
88 error instanceof Error ? error.message : 'Failed to exchange authorization code.';
89 setStatus('error');
90 setMessage(description);
91 }
92 }
93
94 exchangeCode();
95

Callers 1

IntegrationCallbackFunction · 0.85

Calls 2

broadcastConnectionFunction · 0.85
completeOAuthMethod · 0.80

Tested by

no test coverage detected