Skip to content

Commit 62d1d52

Browse files
committed
docs: update git token setup
1 parent 6b9aba9 commit 62d1d52

1 file changed

Lines changed: 43 additions & 30 deletions

File tree

docs/dev/github/github-token-setup.md

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
title: Github Token Setup
33
id: github-token-setup
44
last_update:
5-
date: 08.15.2025
6-
author: Cyber-Syntax
5+
date: 05.21.2026
6+
author: Cyber-Syntax
77
publish:
8-
date: 08.15.2025
8+
date: 08.15.2025
99
tags:
10-
- git
11-
- github
10+
- git
11+
- github
1212
---
1313

1414
<!-- TOC -->
1515

16-
## How to setup fine grained token for authentication?
16+
## 1.Create fine grained token:
1717

1818
1. Go github settings, developer settings, fine grained token.
1919
2. Generate token with permissions:
2020

21-
- User perrmissions is not needed
21+
- User permissions is not needed
2222
- Those are the base ones needed:
2323

24-
## PERMISSIONS
24+
### PERMISSIONS
2525

2626
> Permissions for the fine grained github token
2727
@@ -34,34 +34,28 @@ tags:
3434

3535
- Commit statuses: Read and Write
3636
- Contents: Read and Write
37-
- Commits, branches, downloads, releases and merges
37+
- Commits, branches, downloads, releases and merges
3838
- Issues: Read and write
39-
- For able to make github issue etc. via github cli or other apps
39+
- For able to make github issue etc. via github cli or other apps
4040
- Pages: Read and write
41-
- For github pages
41+
- For github pages
4242
- Pull requests: Read and write
43-
- For able to make github PR etc. via github cli or other apps
43+
- For able to make github PR etc. via github cli or other apps
4444
- Workflows: Read and write
45-
- [?] for able to make a configuration on workflow files like main.yml?
45+
- [?] for able to make a configuration on workflow files like main.yml?
4646
- Metadata: Read-only (Already enabled because mandatory)
4747

4848
## How to not get asked all the time for password for token?
4949

50-
> This happens sometimes when the cache broken on the linux
51-
> or via some updates, or token expration or something bug unknown...
52-
>
53-
> NOTE: Remember, use token for password instead of github password
54-
> when you need to gave it to github cli setup
55-
5650
### Setting up for gnome keyring (Recomended for security)
5751

52+
> [!NOTE]
5853
> This would save your token to your default keyring mostly named `login`
5954
> and you would be prompted from your polkit if you setup a password
6055
> for that keyring.
6156
>
6257
> I recommend you to setup a password(for linux: make it same password with your account to open auto when you login) for your keyring because
63-
> github tokens are basicly password which you need to treat them
64-
> like your personal passwords.
58+
> github tokens are basicly password which you need to treat them like your personal passwords.
6559
6660
1. Setup credential helper to libsecret
6761

@@ -75,26 +69,45 @@ git config --get credential.helper
7569
```
7670

7771
2. When the first initialization for the github like commit, push...
72+
> [!NOTE]
73+
> If you get ask more than ones; This happens sometimes when the cache broken on the linux
74+
> or via some updates, or token expration or something else that I don't know now...
75+
>
76+
> Make sure to setup polkit for your desktop environment or window manager.
7877
7978
```bash
8079
username: <your_exact_github_username>
8180
password: <token_start_with_github_pat_12345>
8281
```
8382

84-
### Plain text save token (Bad security but works)
83+
> [!WARNING]
84+
> Remember, use github token for password section instead of github account password!
8585
86-
```git
87-
git config --global credential.helper store
88-
```
86+
### Using github cli for token handler
8987

90-
If you already have that and nothing happens than configure via plain text on `.git-credentials` this file:
88+
1. Configure gh command authentication to use keyring:
9189

92-
```git
93-
https://1123456:github_pat_1234567123456@github.com
90+
```bash
91+
# Create new txt file to write your fine grained token in it(I do this to note paste to terminal which don't want to deal with history of my zsh file):
92+
touch top-secret
93+
# authenticate gh
94+
gh auth login --git-protocol https --with-token < top-secret
95+
# test
96+
gh auth status
97+
98+
# Example output:
99+
# github.com
100+
# ✓ Logged in to github.com account Cyber-Syntax (keyring)
101+
# - Active account: true
102+
# - Git operations protocol: https
103+
# - Token: github_pat_***********************************************************
94104
```
95105

96-
- `1123456` -> represent github email(mine is private, that's why start with number) starting numbers
97-
- `github_pat_1234567123456` -> represent your token
106+
1. Configure git to use gh for getting token
107+
108+
```bash
109+
gh auth setup-git
110+
```
98111

99112
## Base github config example
100113

0 commit comments

Comments
 (0)