When attempting to delete the Github App from Terraform Enterprise an error may occur.
Failed to authenticate with Github
The response from the provider is missing these required response params: code
In this example, the error was the result of the user account not having permissions in the organization to install Github Apps. In order to delete the Github app, Terraform Enterprise requires the app to be uninstalled on the Github side first and then the connection can be deleted on the Terraform Enterprise side.
The Github App will need to be deleted through the Terraform Enterprise Rails console since the application could not be uninstalled from the Github side.
## Locate the Github App ID in psql
* docker exec -it tfe-atlas sh
* psql $DATABASE_URL
* select * from github_app_app;
* Note app ID
## Locate the VCS host ID in psql
* select * from vcs_hosts;
* Note the ID for the VCS host associated with the github app
## Verify the ID.
* docker exec -ti tfe-atlas /usr/bin/init.sh /app/scripts/wait-for-token -- bash -ic 'cd /app && bin/rails c'
* Vcs::Host.find_by(id: <ID>)
* Verify the ID and that it is correct (ensure the github_app section has values)
* GithubApp::App.find_by(id: <ID>)
## Delete the app
* Vcs::Host.find_by(id: <ID>).destroy!
* GithubApp::App.find_by(id: <ID>).destroy!
The Github App will be removed.