Refined-github: RGH handles only one API Token

Created on 14 Jan 2019  ·  12Comments  ·  Source: sindresorhus/refined-github

Currently if you use RGH on a different domain and GitHub, as soon as you provide a token, the other site no longer works (as expected).

features.js:79 RefinedGitHubAPIError: The token seems to be incorrect or expired. Update it in the options.
    at call (chrome-extension://mnoacfgkaplmhhcgdnekddifjfcllloj/content.js:2481:11)
    at <anonymous>

We need to add the option to specify what URL the token is for and only use it for that domain. This becomes more important if #1713 is merged.

Please! ♥︎ enterprise

Most helpful comment

An alternative solution would be to extend webext-options-sync to have per-domain storage and we’d have automatic per-domain tabs (created by Refined GitHub) in the options.

This is actually kind of possible since webext-options-sync lets you change the storage key (currently stored as options in chrome.storage.sync), we just need to ensure that:

  • supported domains are automatically added to the options page
  • the form updates correctly when the domain tab is changed (perhaps by cloning the form and replacing it)
  • that migrations, defaults and any listeners work correctly and don’t just pile up when switching domain.

https://github.com/sindresorhus/refined-github/pull/2111 contains code useful to generate those tabs (i.e. “what additional domains do we have permission to?”)

All 12 comments

I'd love to fix that, too, but I don't really know where to start.

Do we need the option to specify the URL for a token or do we just need an extra field called GHE personal token? I think that would cover most use cases.

eg.

Screen Shot 2019-05-18 at 12 43 31 PM

The further we go, the more I think this extension needs to be installed once per domain:

  1. works with any number of Enterprise installations
  2. it can be updated when GHE updates, rather than trying to keep RGH working with all versions: https://github.com/sindresorhus/refined-github/issues?q=label%3Aenterprise+label%3Abug

Given that GHE gets features later than regular GitHub, I expect most new features to cause errors so it's always best to wait.

Rather than adding a field, I'd rather see documentation explaining how to:

  • clone and build the extension locally, on a 1 month delay (e.g. HEAD@{ISO date 1 month ago})
  • change the URLs in manifest.json so it applies to your GHE URLs instead of github.com
  • merge in new changes from origin when the user wants to

Even better would be a cli tool that does this automatically, for any extension, like:

npx web-ext-custom-domain sindresorhus/refined-github github.com:github.mycompany.com --delay 30d

# roughly equivalent to
git clone https://github.com/"$1".git .
git checkout HEAD@"$delay"
npm install
npm run build
sed s/"$from_domain"/"$to_domain" distribution/manifest.json
dot-json distribution/manifest.json name "$name ($to_domain)"

I'm not sure that's the right solution since there are still a lot of new features added to refined-github that work well with GHE and if there is a GHE fix you'd probably want to pick up that fix right away. There's only one open bug right now that with the GHE label.

There's only one open bug right now that with the GHE label.

That's because we had to fix (or ignore) all the others

Another option would be to support disabling some features in GHE (like for example recently-pushed-branches-enhancements)... either by:

  • "tagging" some features as targeted for public Github only
  • as an option in the extension (a separate feature blacklist for GHE)

...until they are properly supported in GHE. I don't think this is really necessary though. You can already disable extensions (and will be even easier with https://github.com/sindresorhus/refined-github/pull/1780) which more or less solves the problem.

Another option would be to support disabling some features in GHE

That only gives my suggestion more reason to exist. If you have a GHE-specific extension, you can disable the features that don't work there, just for GHE, without further changes in Refined GitHub.

I don't use Enterprise at all so even if I wanted to I couldn't tell what works there and what doesn't.

I opened a request here: https://github.com/sindresorhus/module-requests/issues/114

I personally prefer having a single "copy" of the extension that updates itself and picks up the latest features and fixes for both public Github and GHE. The main issue is the token issue. I don't think adding a second token text field for GHE really clutters up the extension options? Your other suggestion would work well too I think...

Rather than adding 150 lines of code I'd welcome a raw-er input, e.g. single textarea, comma+line separated input.

I guess the question is what kind of PR would you accept to resolve this issue? Or maybe we need input from other people who use GHE?

No PR other than the tool I described, probably, because if this field is added someone else will ask another field for their second GHE installation (see #1384)

An alternative solution would be to extend webext-options-sync to have per-domain storage and we’d have automatic per-domain tabs (created by Refined GitHub) in the options.

This is actually kind of possible since webext-options-sync lets you change the storage key (currently stored as options in chrome.storage.sync), we just need to ensure that:

  • supported domains are automatically added to the options page
  • the form updates correctly when the domain tab is changed (perhaps by cloning the form and replacing it)
  • that migrations, defaults and any listeners work correctly and don’t just pile up when switching domain.

https://github.com/sindresorhus/refined-github/pull/2111 contains code useful to generate those tabs (i.e. “what additional domains do we have permission to?”)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juliocanares picture juliocanares  ·  3Comments

sompylasar picture sompylasar  ·  3Comments

Arcanemagus picture Arcanemagus  ·  3Comments

supremebeing7 picture supremebeing7  ·  3Comments

mareksuscak picture mareksuscak  ·  3Comments