Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

Does exceeding GitHub api rate limit cause Bad Credentials/401 error?

I had no problem issuing the same query all afternoon.

const query = `{
        owner: "org"
        name: "publicRepo"
      ) {
          first: 2
        ) {
          nodes {
      pageInfo {
    var success = false;
    var makefileName = "";
    await fetch('', {
      method: 'POST',
      body: JSON.stringify({query: query}),
      headers: {
        'Authorization': `Bearer ${accessToken}`,
    }).then(res => res.text())
      .then(body => {
        try {
          var obj = JSON.parse(body); // this is how you parse a string into JSON 
, index) => {
            //do things.....
        } catch (ex) {
      .catch(error => console.error(error));

This is an org I am a part of and a public repo - I don't even think I should have to get an auth token because all of the forks of this repo are public as well? But that's not the issue. 


The issue is that the query worked all afternoon. I got the list of fork names. Then, seemingly out of nowhere, I am getting the following in terminal:

{  message: 'Bad credentials',  documentation_url: ''

And when I run in an online javascript interpreter, I get 

POST 401 (Unauthorized)


Do I need to regenerate the oauth token? I'm using an oauth token generated for a github bot

1 Reply
Community Manager
Message 2 of 2

Re: Does exceeding GitHub api rate limit cause Bad Credentials/401 error?

If you want to check to see if you're running up against rate limits, you can use a simple query like is mentioned in our rate limit documentation. To my knowledge though, no, it shouldn't give you a 401 Unauthorized error when you're running into rate limits.


I hope that helps!