MCPcopy Create free account
hub / github.com/gitify-app/gitify / exchangeAuthCodeForAccessToken

Function exchangeAuthCodeForAccessToken

src/renderer/utils/auth/flows.ts:173–194  ·  view source on GitHub ↗
(
  authCode: AuthCode,
  authOptions: LoginOAuthWebOptions,
)

Source from the content-addressed store, hash-verified

171 * @throws If `clientSecret` is absent.
172 */
173export async function exchangeAuthCodeForAccessToken(
174 authCode: AuthCode,
175 authOptions: LoginOAuthWebOptions,
176): Promise<Token> {
177 if (!authOptions.clientSecret) {
178 throw new Error('clientSecret is required to exchange an auth code');
179 }
180
181 const { authentication } = await exchangeWebFlowCode({
182 clientType: 'oauth-app',
183 clientId: authOptions.clientId,
184 clientSecret: authOptions.clientSecret,
185 code: authCode,
186 request: request.defaults({
187 baseUrl: getGitHubAuthBaseUrl(authOptions.hostname)
188 .toString()
189 .replace(/\/$/, ''),
190 }),
191 });
192
193 return authentication.token as Token;
194}

Callers 1

AppProviderFunction · 0.90

Calls 2

getGitHubAuthBaseUrlFunction · 0.90
toStringMethod · 0.80

Tested by

no test coverage detected