MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / exchangeCodeForTokens

Function exchangeCodeForTokens

scripts/google-oauth-setup.ts:34–53  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

32}
33
34async function exchangeCodeForTokens(code: string): Promise<{ refresh_token: string; access_token: string }> {
35 const response = await fetch('https://oauth2.googleapis.com/token', {
36 method: 'POST',
37 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
38 body: new URLSearchParams({
39 client_id: CLIENT_ID!,
40 client_secret: CLIENT_SECRET!,
41 code,
42 grant_type: 'authorization_code',
43 redirect_uri: REDIRECT_URI,
44 }),
45 });
46
47 if (!response.ok) {
48 const error = await response.text();
49 throw new Error(`Token exchange failed: ${error}`);
50 }
51
52 return response.json();
53}
54
55async function main() {
56 console.log('\n🔐 Google OAuth Setup for Addie\n');

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected