roadie-backstage-plugins icon indicating copy to clipboard operation
roadie-backstage-plugins copied to clipboard

Github token and scope not being requested/add correctly to the GH request for the read me file

Open renatafaracobah opened this issue 1 year ago • 12 comments

Expected Behavior

  • For public github.com repositories, the request for the readme file should not add the GH token to the Authorization header if the token is for a GitHub Enterprise instance.
  • For internal/private repositories, if the user doesn’t have the required scope (repo), the GH login page should be prompt so the user can authorize access to the new scope. login-popup

Current Behavior

  • For public github.com repositories, the request for the readme file is always embedding the GH token even if the token is for an enterprise instance, which can provoke an error response Bad Credentials ( example: https://api.github.com/repos/boozallen/sdp-libraries/readme )
  • For internal/private repositories, if the user doesn’t have the required scope, the card shows the message: Not found and does not prompt the user to log in to update the scope.

Steps to Reproduce

  1. Login to backstage using GitHub enterprise credentials

  2. Given an entity located in a public repository in GitHub (github.com), add the Readme card to that entity’s page.

  3. Go to the page: it shows the Readme card with the error: Bad credentials. bad-credentials-public-repo

  4. Login to backstage using the GitHub credentials and configure the scope to only read:user

  5. Go to an entity page that has the Readme card configured: it shows the card with the error: Not Found. token-only-user-scope

  6. If you go to the same page, now adding the repo scope to the X-Oauth-Scopes header, the card is shown correctly: token-repo-scope

Possible Solution

Context

We are using the GH Insights Roadie plugin to display the Readme file for several entities (components, systems, domains, templates) to encourage our users to go to the docs and find more information.

Your Environment

  • @backstage/plugin-catalog-react version: ^1.8.3
  • @backstage/integration version: ^1.6.2
  • @roadiehq/backstage-plugin-github-insights version: ^2.3.20

renatafaracobah avatar Sep 12 '23 18:09 renatafaracobah

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 11 '23 18:11 github-actions[bot]

unstale please

ltdonner-bah avatar Nov 13 '23 14:11 ltdonner-bah

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 12 '24 14:01 github-actions[bot]

unstale please

ltdonner-bah avatar Jan 12 '24 15:01 ltdonner-bah

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 12 '24 16:03 github-actions[bot]

unstale please

ltdonner-bah avatar Mar 12 '24 16:03 ltdonner-bah

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 11 '24 16:05 github-actions[bot]

unstale please

jladd-bah avatar May 13 '24 13:05 jladd-bah

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 12 '24 13:07 github-actions[bot]

unstale please

jladd-bah avatar Jul 12 '24 13:07 jladd-bah