How can I create personal-access-tokens allowing to read pull request list on a public repository? #183370
Replies: 4 comments 2 replies
-
|
For public repositories, you actually don't need to add any special permissions to your fine-grained personal access token. All tokens inherently have read-only access to public repositories by default. The "Public repositories" option you selected under "Repository access" is sufficient. You can simply leave the Permissions section empty (with "No account permissions added yet") and click "Generate token". The pull_requests and metadata permissions that Copilot suggested are only necessary when you need to access private repositories or when you need write access. For reading pull requests from a public repository, no additional permissions are required. To summarize:
You'll be able to use this token to call the GitHub API and list pull requests from any public repository, for example: Just include your token in the Authorization header and you're good to go! |
Beta Was this translation helpful? Give feedback.
-
|
For public repositories, a fine-grained PAT really does not need any extra permissions to read pull requests. Selecting “Public repositories” under Repository access is enough. You do not need pull_requests: read or metadata: read for this use case. The actual issue in your case was the Authorization header format. What went wrong Classic PATs and fine-grained PATs behave differently here: Classic PAT requires If you send a fine-grained PAT with token , GitHub responds with 403, even for public repos. That explains why: Classic token worked Example request: GET https://api.github.com/repos/openstreetmap/id-tagging-schema/pulls |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Creating a PAT to Read Pull Requests on a Public RepoStep-by-Step1. Go to Token Settings 2. Create a New Token Click "Generate new token" and fill in:
3. Set the Permission Under Permissions → Repository Permissions find: That's the only permission you need. 4. Generate and Copy Click "Generate token" — copy it immediately, GitHub will never show it again. Using the Token to Fetch PRsImportant Notes
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
Yes, I tried LLMs. They hallucinate stuff about nonexisting configurations. For example copilot suggested by Microsoft:
while such permissions cannot be set (see screen below)
at least classic token with no additional permission works?
Beta Was this translation helpful? Give feedback.
All reactions