Skip to content
Back

[SOLVED] Github App "Failed to retrieve access token from GitHub API" v1.8.1

  • 0
  • Resolved
  • 3
  • Self Hosted
Flyto
12 Jan, 2026, 22:46

When trying to connect the Github App on 1.8.1 I recieve this error:

TypeScript
[Error] URL: /v1/vcs/github/callback
[Error] Type: Exception
[Error] Message: Failed to retrieve access token from GitHub API.
[Error] File: /usr/src/code/vendor/utopia-php/vcs/src/VCS/Adapter/Git/GitHub.php
[Error] Line: 398```

ENV should all be set according to docs, Github app as well. Anyone an idea? 

The Callback URL:
GET https://backend.dashly.at/v1/vcs/github/callback?code=8523009ca9352c8911d1&installation_id=103919286&setup_action=update&state=%7B%22projectId%22%3A%2269655ecb000d5ab27c14%22%2C%22success%22%3A%22https%3A%5C%2F%5C%2Fbackend.dashly.at%5C%2Fconsole%5C%2Fproject-default-69655ecb000d5ab27c14%5C%2Fsettings%3Falert%3Dinstallation-updated%22%2C%22failure%22%3A%22https%3A%5C%2F%5C%2Fbackend.dashly.at%5C%2Fconsole%5C%2Fproject-default-69655ecb000d5ab27c14%5C%2Fsettings%3Falert%3Dinstallation-updated%22%7D 500 (Internal Server Error)
TL;DR
GitHub App was facing issues due to incorrect formatting of the private key. The key should be in PEM format with real newlines, not double-escaped or wrapped in quotes. Resolved by ensuring proper key formatting without additional escapes or quotes.
Flashtum
12 Jan, 2026, 22:52

I can help 🙂 This usually happens because Appwrite can’t exchange the GitHub callback code for an access token. The most common cause is an issue with the GitHub App credentials, especially the private key not being set correctly (wrong key, missing line breaks, or not matching the app). It can also happen if the callback URL or app credentials don’t exactly match what GitHub expects. How are you setting the GitHub App private key in your environment (raw PEM, escaped string, or mounted file)? @Flyto

12 Jan, 2026, 23:01

First of all thanks for your help <@1248902535142445057> Maybe I am failing with properly formating the private key. I have been trying multiple times now by replacing line-breaks with \n. The key is correct but maybe its invalid formating? I have an old key here:

"-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAyNF6JCQahhu8nvP7OWzVZCfogJnTaFlBHibJ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zwNnozEjblAnp6p8YTbhpJ43f3hWNeCjS+dSEzzEzH9Ab+RLLSo/GdMR\na9Z0GNPg/cIgTBCh52XRso8DAwST+yrL9WqMTR5P88eQkmzKvh64Vm3REjouAMpU\nz5Ywx7YVf9KevlRpXYBLmJECgYA+ovb84CnIFAwbYGMmtR9XqJOoxi3gAcDx+O+v\nRSYY4eZETdtFLJewOjEzxyjPGk0nT+zIn2AE91T0Sbo2ux9zEIXhd9OfBT0YOc5w\niisQO3hg6KpwbWXnIsp6shzxSZGq5QRkfZJfVGjNYAVGvR9xsovQAZYsL3MpkHAw\n4OBtcwKBgEBkfdbwXfV1qUxoXTx/xYm+3QwtLGieEeVNNoLkfoiP462dDx9IdDNp\nRMR1Fx5SsrNbclB1EncPyLhWXnYdRuLc9TRlY09WRP60MTe9ljUvpIMf0n+tUdtP\n6USyZPppT0UPHl37TjT4Z28/05kALs5PPUF++54PGFwn8eI8rmKj\n-----END RSA PRIVATE KEY-----\n"

12 Jan, 2026, 23:02

I tried both with and without \n at the end...

12 Jan, 2026, 23:08

Thanks for sharing that Yes, this is almost certainly formatting. For Appwrite/GitHub Apps the private key must be exactly the PEM content with real newlines, not double-escaped or wrapped in quotes. If it’s in an .env, it should either be a mounted .pem file or a single line with \n once, no surrounding quotes added by Docker or the shell. What you pasted would fail if it’s being escaped twice.

12 Jan, 2026, 23:09

If you want, we can jump into this chat and I can help you fix it quickly and make sure the GitHub App setup is solid end-to-end. I also do this kind of Appwrite/GitHub integration work professionally, so happy to help beyond just this issue as well.

12 Jan, 2026, 23:11

I appreciate the support. What is wrong with the private key I shared and how would it look correctly? I have seen issues like this in other places but unfortunately could not find a proper explanation how to format correctly. ChatGPT is also halluzinating wildly.

12 Jan, 2026, 23:22

Totally fair question and you’re right, most explanations online are confusing.

12 Jan, 2026, 23:23

Nothing is cryptographically wrong with the key you shared. The problem is how it’s injected, not the key itself. I can help by checking exactly how it’s being passed (env vs file), fixing the formatting so GitHub can parse it correctly, and validating the JWT Appwrite generates from it.

12 Jan, 2026, 23:24

If you want, I’ll walk you through the correct format for your setup and get it working quickly.

12 Jan, 2026, 23:49

If you want to help, feel free to do so here so everyone can se and hopefully learn from it and this question does not need to be raised over and over. But I am not interested in private chat/professional services. I am a student who just wants to figure this shit out...

13 Jan, 2026, 00:30

Alright

13 Jan, 2026, 08:47

[Resolved] Github App "Failed to retrieve access token from GitHub API" v1.8.1

6 Feb, 2026, 17:10

hey bro, i'm student as well. Could u please tell how u solved this? Cuz this one irritates me and even chatgpt was not helping me anymore. Feel free to DM or u can reply me here also.

6 Feb, 2026, 18:21

hey bro, can u help me setup my appwrite on vps?

10 Feb, 2026, 06:22

I got it working but it was a pain...

1
10 Feb, 2026, 08:40

I highly recommend creating a new/separated post

1
10 Feb, 2026, 08:40

[SOLVED] Github App "Failed to retrieve access token from GitHub API" v1.8.1

10 Feb, 2026, 13:13

I solved it by myself... Thank you

1
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more