aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
460 stars 116 forks source link

Authorize GitHub App permission error #2756

Open spazou opened 2 years ago

spazou commented 2 years ago

Before opening, please confirm:

App Id

d1sj4cr45c2t8p

Region

us-east-1

Amplify Hosting feature

No response

Describe the bug

Got an error when i try to Migrate to Amplify GitHub App. Error message : "We do not have permission to access this repository. Please update your permissions and try again."

Github permissions looks correctly set for the repo.

I tried to delete the deploy keys and webhooks but it's not working. And now i can't deploy anymore with the previous OAuth access. So I'm stuck.

Expected behavior

When i click on reconnect the repo, i can migrate to Amplify Github App. The permissions are enough to create deploy keys and webhooks and i can re-connect my repo and deploy my app.

Reproduction steps

  1. Click on the "Start migration" button.
  2. Error shown Capture d’écran 2022-05-17 à 22 32 54
  3. Click on the "update repository permissions" Capture d’écran 2022-05-17 à 22 20 07
  4. All permissions are set for the repo. Can't go further.

Build Settings

No response

Additional information

No response

ghost commented 2 years ago

Hi @spazou 👋🏽 does your repository belong to a GitHub organization? If so, please make sure that the permissions are also given to the organization.

spazou commented 2 years ago

Hi @hloriana no he does not belong to a GitHub organization.

ilia-luk commented 2 years ago

experiencing the same error on us-west-1, I changed the repo name after connecting it, uninstalled, and reconnected my repo again, at the "App settings: General" it still shows with the old URL even after uninstalling the app and reinstalling with max permissions, not sure if related.

the prod build fails with "There was an issue connecting to your repo provider, click "Reconnect repository" in General Settings, and then try your build again." when I follow the advice I encounter the same error as reported.

I do use GitHub organization and the permissions are set on it.

spazou commented 2 years ago

hi @hloriana. Any updates ?

ghost commented 2 years ago

Hi @spazou 👋🏽 thanks for checking in on the issue. We are still root causing this behavior. I'll update this issue as soon as we have a workaround or pushed a fix. Thank you for your patience!

ghost commented 2 years ago

@spazou @ilia-luk if the source repository link is different from what is shown in app -> settings -> general -> source repository url please follow these steps:

  1. Update the repository url via the cli by running this command: aws amplify update-app --app-id --repository-id <value> —access-token <value>
  2. Reconnect repository should be successful
spazou commented 2 years ago

@hloriana It worked. Thank you very much for your help.

dertel commented 2 years ago

Hi @hloriana I'm having this issue with the URL mismatch. But I'm having trouble running your command. I found the app-id but where can I get the values for --repository-id and --access-token? And is it actually --access-token and not -access-token ?

I get the error Unknown options: --repository-id no matter what I put as the value.

FBS-Alex commented 2 years ago

Having the same problem, no matter what I do I can't reconnect the repository and it won't trigger any builds. Are there any updates on this issue? Kind of a breaking bug if I can't deploy any of my apps...

dertel commented 2 years ago

I had to delete the app and recreate it again in order to avoid the problem 🤷 And yes this resulted in significant downtime.

MadeByDouglas commented 2 years ago

Any updates on this? Having same problem, have same questions with repository id and access token.

MadeByDouglas commented 2 years ago

the way I solved this was to delete the branches (essentially deleting front end hosting app) and creating a new one, then it recreates with proper github url and still connects to existing back end environment

tomavanc commented 2 years ago

Solved this by manually deleting the connected branch from the previous repo in General settings. Then I was able to see the new authorized repo with its branches.

patbranchaud commented 2 years ago

Hello, similar problem here.

I get that message : There was an issue connecting to your repo provider, click "Reconnect repository" in General Settings, and then try your build again.

Capture d’écran, le 2022-09-02 à 14 18 56

Connected another branch, it builded first time but started to have the same problem when rebuild.

Repo provider is Github, worked for 3 months and started to have problem today.

cgaege commented 2 years ago

Hello, same issue here. The problem occured after the connected GitHub repo was transfered to an organisation account.

patbranchaud commented 2 years ago

Just a quick follow up : we build our app everyday at midnight and the day after we had the problem, it started working again. It kind of got fixed without any changes by us. So the problem lasted 1 day overall.

samputer commented 2 years ago

I got this to work with the following command, and it successfully reconnected (using the aws cli help commands was helpful):

aws amplify update-app --app-id <app id from amplify> --repository <url eg-https://github.com/MY_ORG/MY_REPO --access-token <GITHUB_PERSONAL_ACCESS_TOKEN>

The Github token can be created at https://github.com/settings/tokens (I gave it all permissions temporarily whilst I ran the command and then revoked the token)

jessedanielsmart commented 1 year ago

Just bringing this issue up again,

We lost connection to our repository when moving it to our organization.

I have tried using @samputer's solution above but keep getting the following error:

Error parsing parameter '--repository': Unable to retrieve https://github.com/**********/**********.git: received non 200 status code of 301

Any assistance here will be helpful.

jessedanielsmart commented 1 year ago

I managed to fix this, here is what I did and what I was doing wrong:

Using this command is correct: aws amplify update-app --app-id <app id from amplify> --repository <url eg-https://github.com/MY_ORG/MY_REPO --access-token <GITHUB_PERSONAL_ACCESS_TOKEN>

However: it only worked for me after doing the following:

  1. In aws I disconnected all the branches.
  2. I needed to active fine grained personl access tokens in GitHub, and then create a new one for my personal account.
  3. I used the ssh repo link rather than this URL.

So my final command was: aws amplify update-app --app-id d2****bb --repository git@github.com:****/*App.git --access-token github_pat_11A***H7

Then in the console I am able to reconnect my branches.

breaker05 commented 1 year ago

Any other solutions to this? I did exactly what @jessedanielsmart recommended and while it did show the reflected and updated repository url, I still get this same exact error.

ckd commented 1 year ago

I had some success by doing basically the following:

  1. Uninstalled the Amplify integration app from my Github organization

  2. Created a second Amplify application and pointed it at the same repo as my original Amplify app.

Since I uninstalled the GitHub App, Amplify will now reauthorize and install it again.

You'll get a notice about the repo already being in use, but you can ignore it- this won't impact any of your existing resources.

  1. Switched to the original app and verified that the Github connection has been restored

  2. Deleted the second Amplify app

  3. In my GitHub repo settings, removed the webhook that the SECOND app created. If for some reason you don't have the webhook for your original Amplify app in there, you can probably get by reusing the new web hook if you update the app_id in the query string.

qaassimq commented 1 year ago

I managed to fix this, here is what I did and what I was doing wrong:

Using this command is correct: aws amplify update-app --app-id <app id from amplify> --repository <url eg-https://github.com/MY_ORG/MY_REPO --access-token <GITHUB_PERSONAL_ACCESS_TOKEN>

However: it only worked for me after doing the following:

  1. In aws I disconnected all the branches.
  2. I needed to active fine grained personl access tokens in GitHub, and then create a new one for my personal account.
  3. I used the ssh repo link rather than this URL.

So my final command was: aws amplify update-app --app-id d2bb --repository git@github.com:/_App.git --access-token github_pat_11A_**H7

Then in the console I am able to reconnect my branches.

Thanks million .. 😃 it works for me

treyn-stripe commented 7 months ago

Confirming I ran into this issue and updating the Amplify app using CLI command with a Token as authentication worked (at least for now) -- will see if still working in a week

tipgo commented 4 months ago

same issue, Failed to fetch repositories from GitHub after authorization

LucileGarnaud commented 5 days ago

Hello, same here I have an issue to migrate to Github App:

-GitHub authorization is successful

There was an issue setting up your repository. Please try again later.({"message":"Resource not accessible by integration","documentation_url":"https://docs.github.com/rest/repos/webhooks#list-repository-webhooks","status":"403"})