MCPcopy Index your code
hub / github.com/anomalyco/opencode / exchangeForAppToken

Function exchangeForAppToken

packages/opencode/src/cli/cmd/github.handler.ts:988–1011  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

986 }
987
988 async function exchangeForAppToken(token: string) {
989 const response = token.startsWith("github_pat_")
990 ? await fetch(`${oidcBaseUrl}/exchange_github_app_token_with_pat`, {
991 method: "POST",
992 headers: {
993 Authorization: `Bearer ${token}`,
994 },
995 body: JSON.stringify({ owner, repo }),
996 })
997 : await fetch(`${oidcBaseUrl}/exchange_github_app_token`, {
998 method: "POST",
999 headers: {
1000 Authorization: `Bearer ${token}`,
1001 },
1002 })
1003
1004 if (!response.ok) {
1005 const responseJson = (await response.json()) as { error?: string }
1006 throw new Error(`App token exchange failed: ${response.status} ${response.statusText} - ${responseJson.error}`)
1007 }
1008
1009 const responseJson = (await response.json()) as { token: string }
1010 return responseJson.token
1011 }
1012
1013 async function configureGit(appToken: string) {
1014 // Do not change git config when running locally

Callers 1

github.handler.tsFile · 0.85

Calls 2

jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected