MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / exchangeRefreshToken

Function exchangeRefreshToken

microsoft-email.js:82–111  ·  view source on GitHub ↗
(clientId, refreshToken, options = {})

Source from the content-addressed store, hash-verified

80 }
81
82 async function exchangeRefreshToken(clientId, refreshToken, options = {}) {
83 const fetchImpl = getFetchImpl(options.fetchImpl);
84 const strategy = resolveTokenStrategy(options.strategyName);
85 const body = new URLSearchParams({
86 client_id: clientId,
87 grant_type: 'refresh_token',
88 refresh_token: refreshToken,
89 ...(strategy.extraData || {}),
90 });
91 const response = await fetchImpl(strategy.url, {
92 method: 'POST',
93 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
94 body: body.toString(),
95 signal: options.signal,
96 });
97
98 if (!response.ok) {
99 throw new Error(`${strategy.name}: ${await getResponseErrorText(response)}`);
100 }
101
102 const data = await response.json();
103 if (!data.access_token) {
104 throw new Error(`${strategy.name}: token response missing access_token`);
105 }
106
107 return {
108 ...data,
109 tokenStrategy: strategy.name,
110 };
111 }
112
113 async function fetchGraphMessages(accessToken, options = {}) {
114 const fetchImpl = getFetchImpl(options.fetchImpl);

Callers 1

Calls 4

getFetchImplFunction · 0.85
resolveTokenStrategyFunction · 0.85
fetchImplFunction · 0.85
getResponseErrorTextFunction · 0.85

Tested by

no test coverage detected