Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub authorization has changed #1755

Closed
lorenx opened this issue Aug 12, 2021 · 25 comments
Closed

GitHub authorization has changed #1755

lorenx opened this issue Aug 12, 2021 · 25 comments

Comments

@lorenx
Copy link

lorenx commented Aug 12, 2021

Hello,
I don't know if you are aware but GitHub has changed its authentication method, on May 5, 2021: see here and here.

In fact, as I try to add my Github repo, StackEdit receives this error:

{
    "status": 400,
    "body": {
        "message": "Must specify access token via Authorization header. https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param",
        "documentation_url": "https://docs.github.com/v3/#oauth2-token-sent-in-a-header"
    }
}

Anyway...
GitLab integration is not working, GitHub is not working either now.
What should we do?

I hope in a quick fix, thank you very much.

@lorenx
Copy link
Author

lorenx commented Aug 12, 2021

I guess it's the same as #1724.
But it doesn't seem fixed...

@unovil
Copy link

unovil commented Aug 13, 2021

{
    "status": 400,
    "body": {
        "message": "Must specify access token via Authorization header. https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param",
        "documentation_url": "https://docs.github.com/v3/#oauth2-token-sent-in-a-header"
    }
}

Anyway...
GitLab integration is not working, GitHub is not working either now.
What should we do?

Same problem here, I granted access to Github so I could sign in from StackEdit and it worked fine, but when I try to add a workspace from Github I get an "HTTP Error 400" sign and this:
image

@lorenx
Copy link
Author

lorenx commented Aug 13, 2021

Yeah, that's the exact error I get too.
It should be simple to change how the token is sent, if only some developers would reply us... @benweet

@leils
Copy link

leils commented Sep 9, 2021

Getting the same exact error, bumping.

@mogoe1
Copy link

mogoe1 commented Sep 14, 2021

For the time being, I developed a workaround. I know there already is #1724 that fixes the issue, but I wanted to keep using StackEdit whilst the request is not yet merged.

Once you are on the screen asking you to "Grant access to your private repositories," open the developer console and paste the following lines.

window.XMLHttpRequest =  class MyXMLHttpRequest extends window.XMLHttpRequest {
  open(...args){
    if(args[1].startsWith("https://api.github.com/user?access_token=")) {
      // apply fix as described by github
      // https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/#changes-to-make
  
      const segments = args[1].split("?");
      args[1] = segments[0]; // remove query params from url
      const token = segments[1].split("=")[1]; // save the token
      
      const ret = super.open(...args);
      
      this.setRequestHeader("Authorization", `token ${token}`); // set required header
      
      return ret;
    }
    else {
      return super.open(...args);
    }
  }
}

This overrides window.XMLHttpRequest, which StackEdit uses to send API-Requests to GitHub, and modifies requests to https://api.github.com/user. Specifically, it moves the token from query to header.

Once the repository is connected, you can remove the overridden XMLHttpRequest by reloading the page.

@jacobhq
Copy link

jacobhq commented Sep 15, 2021

Thank you @mogoe1!

@steffiland
Copy link

Thank you! Ran into this problem this morning...

@albydeca
Copy link

albydeca commented Nov 9, 2021

@benweet Can confirm issue still persists as of today

@tyoc213
Copy link

tyoc213 commented Nov 15, 2021

{
  "message": "Must specify access token via Authorization header. https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param",
  "documentation_url": "https://docs.github.com/v3/#oauth2-token-sent-in-a-header"
}

Yeah, just right now

@yenow
Copy link

yenow commented Nov 25, 2021

@mogoe1 thank you!!!

@baomastr
Copy link

big up @mogoe1

@swoogles
Copy link

Heads up to other recently-frustrated StackEdit users-
From all appearances, the project maintainer is gone. He has had 0 Github activity since March of last year: https://github.com/benweet
I've tried searching for any news items about him, checking for career changes/death announcements/ etc, but without success.
With 8+ months of silence from the solo maintainer, I recommend people start finding/creating alternatives. I know I would be very happy to support someone forking this and taking it into the future :)

@steffiland
Copy link

also had the impression of the project being unmaintained now... meanwhile I switched to Obsidian, which i really love.... Migration is quite easy.

@Squiddim
Copy link

Squiddim commented Apr 1, 2022

This is still an ongoing issue.
Any news on this being added upstream

For the time being, I developed a workaround. I know there already is #1724 that fixes the issue, but I wanted to keep using StackEdit whilst the request is not yet merged.

Once you are on the screen asking you to "Grant access to your private repositories," open the developer console and paste the following lines.

window.XMLHttpRequest =  class MyXMLHttpRequest extends window.XMLHttpRequest {
  open(...args){
    if(args[1].startsWith("https://api.github.com/user?access_token=")) {
      // apply fix as described by github
      // https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/#changes-to-make
  
      const segments = args[1].split("?");
      args[1] = segments[0]; // remove query params from url
      const token = segments[1].split("=")[1]; // save the token
      
      const ret = super.open(...args);
      
      this.setRequestHeader("Authorization", `token ${token}`); // set required header
      
      return ret;
    }
    else {
      return super.open(...args);
    }
  }
}

This overrides window.XMLHttpRequest, which StackEdit uses to send API-Requests to GitHub, and modifies requests to https://api.github.com/user. Specifically, it moves the token from query to header.

Once the repository is connected, you can remove the overridden XMLHttpRequest by reloading the page.

@Lovegiver
Copy link

Thanx a lot. I'm admirative for persons like you who understand something about front end and security ^^

@snowsum
Copy link

snowsum commented Dec 12, 2022

For the time being, I developed a workaround. I know there already is #1724 that fixes the issue, but I wanted to keep using StackEdit whilst the request is not yet merged.

Once you are on the screen asking you to "Grant access to your private repositories," open the developer console and paste the following lines.

window.XMLHttpRequest =  class MyXMLHttpRequest extends window.XMLHttpRequest {
  open(...args){
    if(args[1].startsWith("https://api.github.com/user?access_token=")) {
      // apply fix as described by github
      // https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/#changes-to-make
  
      const segments = args[1].split("?");
      args[1] = segments[0]; // remove query params from url
      const token = segments[1].split("=")[1]; // save the token
      
      const ret = super.open(...args);
      
      this.setRequestHeader("Authorization", `token ${token}`); // set required header
      
      return ret;
    }
    else {
      return super.open(...args);
    }
  }
}

This overrides window.XMLHttpRequest, which StackEdit uses to send API-Requests to GitHub, and modifies requests to https://api.github.com/user. Specifically, it moves the token from query to header.

Once the repository is connected, you can remove the overridden XMLHttpRequest by reloading the page.

@ocundale
Copy link

also had the impression of the project being unmaintained now... meanwhile I switched to Obsidian, which i really love.... Migration is quite easy.

Thank you - great recommendation! :)

@obmotum
Copy link

obmotum commented Feb 1, 2023

For the time being, I developed a workaround. I know there already is #1724 that fixes the issue, but I wanted to keep using StackEdit whilst the request is not yet merged.

Once you are on the screen asking you to "Grant access to your private repositories," open the developer console and paste the following lines.

window.XMLHttpRequest =  class MyXMLHttpRequest extends window.XMLHttpRequest {
  open(...args){
    if(args[1].startsWith("https://api.github.com/user?access_token=")) {
      // apply fix as described by github
      // https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/#changes-to-make
  
      const segments = args[1].split("?");
      args[1] = segments[0]; // remove query params from url
      const token = segments[1].split("=")[1]; // save the token
      
      const ret = super.open(...args);
      
      this.setRequestHeader("Authorization", `token ${token}`); // set required header
      
      return ret;
    }
    else {
      return super.open(...args);
    }
  }
}

This overrides window.XMLHttpRequest, which StackEdit uses to send API-Requests to GitHub, and modifies requests to https://api.github.com/user. Specifically, it moves the token from query to header.

Once the repository is connected, you can remove the overridden XMLHttpRequest by reloading the page.

Thank you @snowsum. This has helped me today (01.02.2023)

@omerfsen
Copy link

Same here ... Above code snippet worked for me (16.02.2023). I do afraid something happened to this developer. Hope he is alive.

@houserockr
Copy link

Same here, JS snippet worked for me (16.03.2023)
Also, the fact that I even have to do this is fvking annoying.

@pamoroso
Copy link

pamoroso commented May 3, 2023

I still get the error despite the workaround. Any chances of fixing the issue for good by merging #1724?

@rx-ted
Copy link

rx-ted commented May 11, 2023

Thank you @mogoe1!

@R-Rudolf
Copy link

R-Rudolf commented May 15, 2023

It is clear that it won't be fixed, the maintainer basically left this project.

I switched to using Github itself for note taking, it has great editor features, even on mobile.
But to create new file on mobile, I use this app:
GitJournal. The version controll sounds like a nice feature in this flow :)

I tried free tier of some paid software as Obsidian/Notion, but for me they did not fit. In PM I am open for similar free software recommendations.

@benweet
Copy link
Owner

benweet commented May 15, 2023

Should be fixed with v5.15.0.

@benweet benweet closed this as completed May 15, 2023
@ghost
Copy link

ghost commented Mar 3, 2024

Heads up to other recently-frustrated StackEdit users- From all appearances, the project maintainer is gone. He has had 0 Github activity since March of last year: https://github.com/benweet I've tried searching for any news items about him, checking for career changes/death announcements/ etc, but without success. With 8+ months of silence from the solo maintainer, I recommend people start finding/creating alternatives. I know I would be very happy to support someone forking this and taking it into the future :)

did you end up forking it.?
let me know I can contribute, I love this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests