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

Rate limit still set to 60 even after applying a PAT. #382

Closed
kaykhan opened this issue Nov 17, 2023 · 2 comments
Closed

Rate limit still set to 60 even after applying a PAT. #382

kaykhan opened this issue Nov 17, 2023 · 2 comments

Comments

@kaykhan
Copy link

kaykhan commented Nov 17, 2023

Hi i have created a PAT on a github account and im trying to see if the rate limit has increased to 5000 as suggested by the following documentation. https://docs.github.com/en/rest/overview/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-authenticated-users

But despite supplying the PAT i am still only getting 60 rate limit value.

What is happening here? Could the rateLimit function not be applying the auth token?

import { Octokit } from "@octokit/rest";

async function GetAPIRateLimit() {
    const octokit = new Octokit({
        auth: "token_redacted",
    });

    const ratel = await octokit.rateLimit.get();
    console.log(ratel);
}

GetAPIRateLimit();
{
  status: 200,
  url: 'https://api.github.com/rate_limit',
  headers: {
    'access-control-allow-origin': '*',
    'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
    'cache-control': 'no-cache',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Fri, 17 Nov 2023 10:44:22 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    vary: 'Accept-Encoding, Accept, X-Requested-With',
    'x-accepted-oauth-scopes': '',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-api-version-selected': '2022-11-28',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': 'C3F4:79B9:3C733C:7D4144:af',
    'x-oauth-scopes': 'admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages',
    'x-ratelimit-limit': '60',
    'x-ratelimit-remaining': '60',
    'x-ratelimit-reset': '1700221462',
    'x-ratelimit-resource': 'core',
    'x-ratelimit-used': '0',
    'x-xss-protection': '0'
  },
  data: {
    resources: {
      core: [Object],
      search: [Object],
      graphql: [Object],
      integration_manifest: [Object],
      source_import: [Object],
      code_scanning_upload: [Object],
      actions_runner_registration: [Object],
      scim: [Object],
      dependency_snapshots: [Object],
      audit_log: [Object],
      code_search: [Object]
    },
    rate: { limit: 60, used: 0, remaining: 60, reset: 1700221462 }
  }
}

Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@gr2m
Copy link
Contributor

gr2m commented Nov 17, 2023

I cannot reproduce the problem. Most likely the token you are setting is undefined. The request headers in your error do not show the authorization header that means that octokit does not have a token.

It might be a good idea to through a helpful error when the auth option is set to undefined or an empty string to help folks catch problems more easily 🤔

@gr2m gr2m closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants