[SOLVED] Github App "Failed to retrieve access token from GitHub API" v1.8.1
- 0
- Resolved
- 3
- Self Hosted
When trying to connect the Github App on 1.8.1 I recieve this error:
[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)
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
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-----\nMIIEowIBAAKCAQEAyNF6JCQahhu8nvP7OWzVZCfogJnTaFlBHibJ2Ay0gpDLLxEj\nvp3UW5t1dtfcK8bndw9BUyW7iQriUw1VeXsrDMknN9q+WtBqfN9bcnmgN4FH6nYc\n976PWabbo4d3JCQwn/RiOWciLx1ro0aSjdp5MJl8J8F/4Ew6/icw9W4w/KYpaHep\nM7/dr/9TuBkS85oVVl5ekpKm0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JOoxi3gAcDx+O+v\nRSYY4eZETdtFLJewOjEzxyjPGk0nT+zIn2AE91T0Sbo2ux9zEIXhd9OfBT0YOc5w\niisQO3hg6KpwbWXnIsp6shzxSZGq5QRkfZJfVGjNYAVGvR9xsovQAZYsL3MpkHAw\n4OBtcwKBgEBkfdbwXfV1qUxoXTx/xYm+3QwtLGieEeVNNoLkfoiP462dDx9IdDNp\nRMR1Fx5SsrNbclB1EncPyLhWXnYdRuLc9TRlY09WRP60MTe9ljUvpIMf0n+tUdtP\n6USyZPppT0UPHl37TjT4Z28/05kALs5PPUF++54PGFwn8eI8rmKj\n-----END RSA PRIVATE KEY-----\n"
I tried both with and without \n at the end...
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.
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.
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.
Totally fair question and you’re right, most explanations online are confusing.
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.
If you want, I’ll walk you through the correct format for your setup and get it working quickly.
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...
Alright
[Resolved] Github App "Failed to retrieve access token from GitHub API" v1.8.1
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.
hey bro, can u help me setup my appwrite on vps?
[SOLVED] Github App "Failed to retrieve access token from GitHub API" v1.8.1
Recommended threads
- local (self-hosted) sites issues
setup: - `composer run installer:dev` issues - Getting error when visiting the site ```Synchronous function execution timed out. Use asynchronous execution in...
- I'm getting an error on the console "j?....
On my self hosted instance version 1.8.1 the console is giving me this error when trying to view the rows for a table I recently created. My application is read...
- local build `composer installer:dev` iss...
setup - dev container (default linux universal) WSL (test with gh codespace too) - php 8.5.7 - all extensions installed - `composer install` fine - `composer...