diff --git a/packages/shared/src/github/auth.ts b/packages/shared/src/github/auth.ts index fbea3f8b..6c90812e 100644 --- a/packages/shared/src/github/auth.ts +++ b/packages/shared/src/github/auth.ts @@ -1,5 +1,8 @@ import { generateJWT } from "../jwt.js"; +const replaceNewlinesWithBackslashN = (str: string) => + str.replace(/\n/g, "\\n"); + /** * Gets an installation access token for a GitHub App installation */ @@ -8,7 +11,10 @@ export async function getInstallationToken( appId: string, privateKey: string, ): Promise { - const jwtToken = generateJWT(appId, privateKey); + const jwtToken = generateJWT( + appId, + replaceNewlinesWithBackslashN(privateKey), + ); const response = await fetch( `https://api.github.com/app/installations/${installationId}/access_tokens`,