DEV Community

Cover image for Conveniently link users to a pre-filled New GitHub Personal Access Token Page
Dak Washbrook
Dak Washbrook

Posted on

3 3

Conveniently link users to a pre-filled New GitHub Personal Access Token Page

My use case was allowing users to update a CLI tool directly from a private repo's releases that they would already have access to. The CLI tool required a valid GitHub access token with specific permissions.

To make this easy for the users, I wanted the CLI tool to open up directly into a pre-filled permissions page, instead of having to fill it in based on a README.md entry.

I dug around the page for the id of the input fields to see if I could use those to pre-fill. After trying a few variations I found it!

The base URL is

https://github.com/settings/tokens/new
Enter fullscreen mode Exit fullscreen mode

Appending the following query parameters onto the URL allows us to pre-fill the form.

For Example:

https://github.com/settings/tokens/new?description=my-cli-tool&scopes=repo,read:packages,read:org
Enter fullscreen mode Exit fullscreen mode

description fills the "Note" field.
scopes allows for a comma-separated list of the scopes.

Now your user only needs to press "Generate token" at the bottom of the page.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
fennecdjay profile image
Jérémie Astor

Thanks!
I made a simple tool to use github discussions from the command line, which requires a PAT. This seems like something to put in its README 😄

....

Looking at the project, I have to create a README first 😕
...

Collapse
 
nikelborm profile image
nikel

It also supports the default_expires_at query parameter which can be 30, 90, or any other amount of days, or the special value none to make the access token never expire.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay