@mherod/get-cookie 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Demonstration of the --list-profiles feature
4
- echo "🍪 Profile Listing Feature Demo"
5
- echo "==============================="
6
- echo ""
7
-
8
- echo "The new --list-profiles option helps you discover available browser profiles"
9
- echo "before using them with the --profile option."
10
- echo ""
11
-
12
- # Basic usage
13
- echo "📋 Basic Usage:"
14
- echo "─────────────"
15
- echo "$ get-cookie --browser chrome --list-profiles"
16
- echo ""
17
- get-cookie --browser chrome --list-profiles
18
- echo ""
19
-
20
- # Show how it integrates with profile selection
21
- echo "🔗 Integration with Profile Selection:"
22
- echo "────────────────────────────────────"
23
- echo ""
24
- echo "Step 1: List available profiles"
25
- echo "$ get-cookie --browser chrome --list-profiles"
26
- echo ""
27
- echo "Step 2: Use a specific profile name from the list"
28
- echo "$ get-cookie --url https://github.com --browser chrome --profile \"plugg.in\" --render"
29
- echo ""
30
-
31
- # Demonstrate actual usage
32
- echo "Example: Getting cookies from a specific profile"
33
- echo ""
34
- PROFILE_NAME="plugg.in"
35
- if get-cookie --browser chrome --list-profiles 2>/dev/null | grep -q "$PROFILE_NAME"; then
36
- echo "✓ Profile '$PROFILE_NAME' found"
37
- echo ""
38
- echo "Getting GitHub session from '$PROFILE_NAME' profile:"
39
- SESSION=$(get-cookie user_session github.com --browser chrome --profile "$PROFILE_NAME" --render 2>/dev/null)
40
- if [ -n "$SESSION" ]; then
41
- VALUE=$(echo "$SESSION" | cut -d'=' -f2)
42
- echo " user_session=${VALUE:0:20}... (${#VALUE} chars)"
43
- else
44
- echo " No session cookie found"
45
- fi
46
- else
47
- echo "Profile '$PROFILE_NAME' not found"
48
- fi
49
- echo ""
50
-
51
- # Show error handling
52
- echo "⚠️ Error Handling:"
53
- echo "────────────────"
54
- echo ""
55
- echo "Without --browser flag:"
56
- echo "$ get-cookie --list-profiles"
57
- get-cookie --list-profiles 2>&1 | head -2
58
- echo ""
59
-
60
- echo "With unsupported browser:"
61
- echo "$ get-cookie --browser safari --list-profiles"
62
- get-cookie --browser safari --list-profiles 2>&1
63
- echo ""
64
-
65
- # Show all supported browsers
66
- echo "🌐 Supported Browsers:"
67
- echo "───────────────────"
68
- echo ""
69
- echo "Chromium-based browsers with profile support:"
70
- echo " • chrome - Google Chrome"
71
- echo " • edge - Microsoft Edge"
72
- echo " • arc - Arc Browser"
73
- echo " • opera - Opera"
74
- echo " • opera-gx - Opera GX"
75
- echo ""
76
- echo "Other browsers:"
77
- echo " • firefox - Profile listing coming soon"
78
- echo " • safari - No profile support (uses system keychain)"
79
- echo ""
80
-
81
- # Practical workflow
82
- echo "💼 Practical Workflow:"
83
- echo "───────────────────"
84
- echo ""
85
- cat << 'EOF'
86
- # 1. Check which profiles are available
87
- get-cookie --browser chrome --list-profiles
88
-
89
- # 2. Choose the profile with the right session
90
- # (e.g., "Work" for company repos, "Personal" for personal)
91
-
92
- # 3. Extract cookies from that specific profile
93
- COOKIES=$(get-cookie --url https://github.com \
94
- --browser chrome \
95
- --profile "Work" \
96
- --render)
97
-
98
- # 4. Use with curl for authenticated requests
99
- curl -H "Cookie: $COOKIES" https://github.com/company/private-repo
100
- EOF
101
- echo ""
102
-
103
- # Show JSON output option
104
- echo "📊 JSON Output Option:"
105
- echo "──────────────────"
106
- echo ""
107
- echo "For scripting, combine with JSON output:"
108
- echo '$ get-cookie --url https://example.com --browser chrome --profile "Work" --output json | jq ...'
109
- echo ""
110
-
111
- # Summary
112
- echo "✨ Summary:"
113
- echo "─────────"
114
- echo "• Use --list-profiles to discover available profiles"
115
- echo "• Profile names are shown with their directory mappings"
116
- echo "• User email is displayed when available"
117
- echo "• Works with all Chromium-based browsers"
118
- echo "• Essential for managing multiple logged-in sessions"
119
- echo ""
120
- echo "✅ The --list-profiles feature makes profile selection easy and discoverable!"
@@ -1,120 +0,0 @@
1
- #!/bin/bash
2
-
3
- # PROPER usage of get-cookie with --url and --render for curl
4
- echo "✅ Correct get-cookie Usage with --url and --render"
5
- echo "==================================================="
6
- echo ""
7
-
8
- # The CORRECT way to use get-cookie with curl
9
- echo "📌 The Right Pattern:"
10
- echo "────────────────────"
11
- echo 'curl -H "Cookie: $(get-cookie --url <URL> --render)" <URL>'
12
- echo ""
13
-
14
- # Test 1: Simple check - what cookies do we get?
15
- echo "1️⃣ Checking cookies for GitHub settings:"
16
- COOKIES=$(get-cookie --url https://github.com/settings/profile --render 2>/dev/null)
17
- echo " Cookie string length: $(echo "$COOKIES" | wc -c) characters"
18
- echo " Number of cookies: $(echo "$COOKIES" | grep -o ';' | wc -l | xargs expr 1 +)"
19
- echo ""
20
-
21
- # Test 2: Real-world usage - accessing authenticated content
22
- echo "2️⃣ Testing authenticated access to GitHub:"
23
- echo ""
24
-
25
- test_url_with_cookies() {
26
- local url=$1
27
- local description=$2
28
-
29
- echo "• Testing: $description"
30
- echo " URL: $url"
31
-
32
- # Get cookies for this specific URL
33
- local cookies=$(get-cookie --url "$url" --render 2>/dev/null)
34
-
35
- # Make the request
36
- local response=$(curl -s -L \
37
- -H "Cookie: $cookies" \
38
- -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \
39
- -H "Accept: text/html,application/xhtml+xml" \
40
- "$url")
41
-
42
- # Check if we're authenticated
43
- if echo "$response" | grep -q "Sign in to GitHub" > /dev/null 2>&1; then
44
- echo " ❌ Not authenticated (redirected to login)"
45
- elif echo "$response" | grep -q "<title>.*Settings.*</title>" > /dev/null 2>&1; then
46
- echo " ✅ Authenticated! (reached settings page)"
47
- elif echo "$response" | grep -q "Your profile" > /dev/null 2>&1; then
48
- echo " ✅ Authenticated! (reached profile page)"
49
- else
50
- local title=$(echo "$response" | grep -o "<title>[^<]*</title>" | head -1)
51
- echo " ℹ️ Page title: $title"
52
- fi
53
- echo ""
54
- }
55
-
56
- # Test various GitHub pages
57
- test_url_with_cookies "https://github.com/settings/profile" "GitHub Settings"
58
- test_url_with_cookies "https://github.com/new" "New Repository Page"
59
-
60
- # Test 3: Working with other sites
61
- echo "3️⃣ Testing with other sites:"
62
- echo ""
63
-
64
- # Stack Overflow
65
- SO_COOKIES=$(get-cookie --url https://stackoverflow.com/users/edit --render 2>/dev/null)
66
- if [ -n "$SO_COOKIES" ]; then
67
- echo "• Stack Overflow:"
68
- SO_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
69
- -H "Cookie: $SO_COOKIES" \
70
- -H "User-Agent: Mozilla/5.0" \
71
- "https://stackoverflow.com/users/edit")
72
- echo " HTTP Status: $SO_STATUS"
73
- [ "$SO_STATUS" = "200" ] && echo " ✅ Authenticated" || echo " ❌ Not authenticated"
74
- else
75
- echo "• Stack Overflow: No cookies found"
76
- fi
77
- echo ""
78
-
79
- # Test 4: Practical one-liners
80
- echo "4️⃣ Practical One-Liners That Work:"
81
- echo "───────────────────────────────────"
82
- echo ""
83
- echo "# Download a file with authentication:"
84
- echo 'curl -O -H "Cookie: $(get-cookie --url https://example.com/file.pdf --render)" https://example.com/file.pdf'
85
- echo ""
86
- echo "# Check if you're logged in:"
87
- echo 'curl -s -H "Cookie: $(get-cookie --url https://github.com/settings --render)" https://github.com/settings | grep -q "Sign in" && echo "Not logged in" || echo "Logged in"'
88
- echo ""
89
- echo "# Save response with cookies:"
90
- echo 'curl -H "Cookie: $(get-cookie --url https://example.com --render)" https://example.com > page.html'
91
- echo ""
92
-
93
- # Test 5: Debugging when it doesn't work
94
- echo "5️⃣ Debugging Tips:"
95
- echo "─────────────────"
96
- echo ""
97
- echo "If authentication isn't working:"
98
- echo ""
99
- echo "1. Check cookie quality:"
100
- echo ' get-cookie --url <URL> --output json | jq '"'"'.[] | {name, value: .value[:20], len: (.value | length)}'"'"
101
- echo ""
102
- echo "2. Check for expired cookies:"
103
- echo ' get-cookie --url <URL> --output json | jq '"'"'.[] | select(.expiry < now | todate)'"'"
104
- echo ""
105
- echo "3. Try specific browser profiles:"
106
- echo ' get-cookie --url <URL> --browser chrome --render'
107
- echo ""
108
-
109
- # The key insight
110
- echo "⚠️ Important Note:"
111
- echo "──────────────────"
112
- echo "Some sites (like GitHub) may have multiple session cookies across different"
113
- echo "browser profiles. The --url flag gets ALL matching cookies, which may include"
114
- echo "invalid ones. For production use, you might need to:"
115
- echo ""
116
- echo "1. Use --browser to target a specific browser"
117
- echo "2. Use --output json and filter for valid cookies"
118
- echo "3. Check cookie expiration dates"
119
- echo ""
120
- echo "✅ The CLI is working correctly - it's faithfully extracting what the browsers have stored!"
@@ -1,95 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Simple and practical get-cookie + curl integration using --render
4
- echo "🍪 get-cookie + curl Integration (using --render)"
5
- echo "=================================================="
6
-
7
- # The --render flag outputs cookies in the perfect format for curl: name=value
8
-
9
- # Example 1: Single cookie with curl
10
- echo -e "\n1️⃣ Getting GitHub user session cookie..."
11
- USER_SESSION=$(get-cookie user_session github.com --render 2>/dev/null)
12
-
13
- if [ -n "$USER_SESSION" ]; then
14
- echo " ✅ Got cookie: ${USER_SESSION:0:30}..."
15
-
16
- # Use directly with curl
17
- echo -e "\n2️⃣ Using cookie with GitHub API..."
18
- curl -s \
19
- -H "Cookie: $USER_SESSION" \
20
- -H "User-Agent: get-cookie-demo" \
21
- "https://api.github.com/user" | jq -r '.login' | while read LOGIN; do
22
- if [ -n "$LOGIN" ] && [ "$LOGIN" != "null" ]; then
23
- echo " ✅ Authenticated as: @$LOGIN"
24
- else
25
- echo " ⚠️ Cookie didn't work for API (may need different cookie)"
26
- fi
27
- done
28
- else
29
- echo " ❌ No user_session cookie found"
30
- fi
31
-
32
- # Example 2: Multiple cookies (semicolon separated)
33
- echo -e "\n3️⃣ Getting multiple GitHub cookies..."
34
- COOKIES=""
35
- for cookie_name in "user_session" "dotcom_user" "__Host-user_session_same_site" "_gh_sess"; do
36
- COOKIE=$(get-cookie "$cookie_name" github.com --render 2>/dev/null | head -1)
37
- if [ -n "$COOKIE" ]; then
38
- [ -n "$COOKIES" ] && COOKIES="$COOKIES; "
39
- COOKIES="$COOKIES$COOKIE"
40
- echo " ✅ Added: ${cookie_name}"
41
- fi
42
- done
43
-
44
- if [ -n "$COOKIES" ]; then
45
- echo -e "\n4️⃣ Testing authenticated page access..."
46
- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
47
- -H "Cookie: $COOKIES" \
48
- -H "User-Agent: Mozilla/5.0" \
49
- "https://github.com/settings/profile")
50
-
51
- echo " HTTP Response: $HTTP_CODE"
52
- [ "$HTTP_CODE" = "200" ] && echo " ✅ Successfully accessed protected page!"
53
- fi
54
-
55
- # Example 3: Direct one-liner for API calls
56
- echo -e "\n5️⃣ One-liner examples:"
57
- echo "────────────────────"
58
- echo ""
59
- echo "# Get user info with single command:"
60
- echo 'curl -s -H "Cookie: $(get-cookie user_session github.com --render)" https://api.github.com/user | jq .login'
61
- echo ""
62
-
63
- echo "# Download file with authentication:"
64
- echo 'curl -H "Cookie: $(get-cookie user_session github.com --render)" -o file.zip https://github.com/user/repo/archive/main.zip'
65
- echo ""
66
-
67
- echo "# Using with wget:"
68
- echo 'wget --header="Cookie: $(get-cookie user_session github.com --render)" https://github.com/user/private-repo'
69
- echo ""
70
-
71
- echo "# Using with HTTPie:"
72
- echo 'http https://api.github.com/user "Cookie:$(get-cookie user_session github.com --render)"'
73
-
74
- # Example 4: Practical use case - checking star count
75
- echo -e "\n6️⃣ Practical example: Check if you've starred a repo..."
76
- COOKIE=$(get-cookie user_session github.com --render 2>/dev/null | head -1)
77
- if [ -n "$COOKIE" ]; then
78
- STARRED=$(curl -s -H "Cookie: $COOKIE" \
79
- -H "User-Agent: get-cookie-demo" \
80
- "https://api.github.com/user/starred/mherod/get-cookie" \
81
- -w "%{http_code}" -o /dev/null)
82
-
83
- if [ "$STARRED" = "204" ]; then
84
- echo " ⭐ You've starred mherod/get-cookie!"
85
- elif [ "$STARRED" = "404" ]; then
86
- echo " ☆ You haven't starred mherod/get-cookie yet"
87
- else
88
- echo " ⚠️ Couldn't check star status (HTTP $STARRED)"
89
- fi
90
- fi
91
-
92
- echo -e "\n✅ Demo complete!"
93
- echo ""
94
- echo "💡 TIP: The --render flag outputs cookies in 'name=value' format,"
95
- echo " perfect for direct use with curl's Cookie header!"
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Test the expired cookie filtering feature
4
- echo "🔍 Testing Expired Cookie Filtering"
5
- echo "===================================="
6
- echo ""
7
-
8
- # Test 1: Check default behavior (should filter expired)
9
- echo "1️⃣ Default behavior (filters expired cookies):"
10
- echo "─────────────────────────────────────────────"
11
- DEFAULT_COUNT=$(get-cookie --url https://github.com --output json 2>/dev/null | jq 'length')
12
- echo " Cookies returned: $DEFAULT_COUNT"
13
- echo ""
14
-
15
- # Test 2: Check with --include-expired flag
16
- echo "2️⃣ With --include-expired flag:"
17
- echo "────────────────────────────────"
18
- WITH_EXPIRED_COUNT=$(get-cookie --url https://github.com --output json --include-expired 2>/dev/null | jq 'length')
19
- echo " Cookies returned: $WITH_EXPIRED_COUNT"
20
- echo ""
21
-
22
- # Test 3: Compare the difference
23
- echo "3️⃣ Analysis:"
24
- echo "───────────"
25
- if [ "$WITH_EXPIRED_COUNT" -gt "$DEFAULT_COUNT" ]; then
26
- DIFF=$((WITH_EXPIRED_COUNT - DEFAULT_COUNT))
27
- echo " ✅ Filtering is working! Removed $DIFF expired cookies"
28
- else
29
- echo " ℹ️ No expired cookies found (or same count)"
30
- fi
31
- echo ""
32
-
33
- # Test 4: Show example cookies with expiry info
34
- echo "4️⃣ Sample cookies with expiry info:"
35
- echo "──────────────────────────────────"
36
- echo "Default (non-expired only):"
37
- get-cookie --url https://github.com --output json 2>/dev/null | jq -r '.[:3] | .[] | " • \(.name): expires \(if .expiry then (.expiry | todate) else "session" end)"'
38
- echo ""
39
-
40
- echo "With expired included:"
41
- get-cookie --url https://github.com --output json --include-expired 2>/dev/null | jq -r '.[:3] | .[] | " • \(.name): expires \(if .expiry then (.expiry | todate) else "session" end)"'
42
- echo ""
43
-
44
- # Test 5: Practical curl test
45
- echo "5️⃣ Practical test with curl:"
46
- echo "──────────────────────────"
47
- echo "Testing GitHub authentication with filtered cookies..."
48
- COOKIES=$(get-cookie --url https://github.com/settings/profile --render 2>/dev/null)
49
- RESPONSE=$(curl -s -L \
50
- -H "Cookie: $COOKIES" \
51
- -H "User-Agent: Mozilla/5.0" \
52
- "https://github.com/settings/profile" | grep -o "<title>[^<]*</title>" | head -1)
53
-
54
- if echo "$RESPONSE" | grep -q "Your profile"; then
55
- echo "✅ Authentication successful with filtered cookies!"
56
- elif echo "$RESPONSE" | grep -q "Sign in"; then
57
- echo "❌ Authentication failed (redirected to sign in)"
58
- else
59
- echo "ℹ️ Response: $RESPONSE"
60
- fi
61
- echo ""
62
-
63
- echo "💡 Summary:"
64
- echo "─────────"
65
- echo "The --include-expired flag controls whether expired cookies are included."
66
- echo "By default, expired cookies are filtered out for better authentication success."
67
- echo ""
68
- echo "✅ Feature is working as expected!"
@@ -1,245 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Test what GitHub content we can actually access with browser cookies
4
- echo "🔐 Testing GitHub Private Access with Browser Cookies"
5
- echo "====================================================="
6
- echo ""
7
-
8
- # Get all GitHub cookies
9
- COOKIES=$(get-cookie --url https://github.com --render 2>/dev/null)
10
-
11
- if [ -z "$COOKIES" ]; then
12
- echo "❌ No GitHub cookies found. Please log into GitHub in your browser."
13
- exit 1
14
- fi
15
-
16
- echo "✅ Found GitHub cookies ($(echo "$COOKIES" | grep -o ';' | wc -l | xargs expr 1 +) cookies)"
17
- echo ""
18
-
19
- # Extract username from cookies
20
- USERNAME=$(get-cookie dotcom_user github.com --render 2>/dev/null | cut -d'=' -f2 | cut -d';' -f1)
21
- if [ -n "$USERNAME" ]; then
22
- echo "👤 Detected GitHub username: $USERNAME"
23
- else
24
- echo "⚠️ Could not detect username from cookies"
25
- USERNAME="mherod" # fallback for testing
26
- fi
27
-
28
- echo ""
29
- echo "Testing various GitHub endpoints..."
30
- echo "────────────────────────────────────"
31
-
32
- # Function to test GitHub endpoints
33
- test_endpoint() {
34
- local name=$1
35
- local url=$2
36
- local check_string=$3
37
-
38
- echo -n "• $name: "
39
-
40
- RESPONSE=$(curl -s -L \
41
- -H "Cookie: $COOKIES" \
42
- -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" \
43
- -H "Accept: text/html,application/xhtml+xml" \
44
- "$url")
45
-
46
- HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
47
- -H "Cookie: $COOKIES" \
48
- -H "User-Agent: Mozilla/5.0" \
49
- "$url")
50
-
51
- if echo "$RESPONSE" | grep -q "$check_string" > /dev/null 2>&1; then
52
- echo "✅ Authenticated (HTTP $HTTP_CODE)"
53
- return 0
54
- elif [ "$HTTP_CODE" = "200" ]; then
55
- echo "⚠️ Accessible but not authenticated (HTTP 200)"
56
- return 1
57
- elif [ "$HTTP_CODE" = "404" ]; then
58
- echo "❌ Not found (HTTP 404)"
59
- return 1
60
- elif [ "$HTTP_CODE" = "302" ] || [ "$HTTP_CODE" = "301" ]; then
61
- echo "🔄 Redirected - not authenticated (HTTP $HTTP_CODE)"
62
- return 1
63
- else
64
- echo "❌ Failed (HTTP $HTTP_CODE)"
65
- return 1
66
- fi
67
- }
68
-
69
- # Test public profile (should work either way)
70
- test_endpoint "Public profile" \
71
- "https://github.com/$USERNAME" \
72
- "Follow"
73
-
74
- # Test settings page (requires authentication)
75
- test_endpoint "Settings page" \
76
- "https://github.com/settings/profile" \
77
- "Public profile"
78
-
79
- # Test notifications (requires authentication)
80
- test_endpoint "Notifications" \
81
- "https://github.com/notifications" \
82
- "notifications"
83
-
84
- # Test security settings (requires authentication)
85
- test_endpoint "Security settings" \
86
- "https://github.com/settings/security" \
87
- "Two-factor"
88
-
89
- # Test SSH keys page (requires authentication)
90
- test_endpoint "SSH keys" \
91
- "https://github.com/settings/keys" \
92
- "SSH keys"
93
-
94
- echo ""
95
- echo "Testing repository access..."
96
- echo "────────────────────────────"
97
-
98
- # Test accessing this repository (get-cookie)
99
- echo -n "• get-cookie repo: "
100
- REPO_RESPONSE=$(curl -s -L \
101
- -H "Cookie: $COOKIES" \
102
- -H "User-Agent: Mozilla/5.0" \
103
- "https://github.com/$USERNAME/get-cookie")
104
-
105
- if echo "$REPO_RESPONSE" | grep -q "Code" > /dev/null 2>&1; then
106
- echo "✅ Can access"
107
-
108
- # Check if we can see the clone button (indicates authenticated access)
109
- if echo "$REPO_RESPONSE" | grep -q "Use Git or checkout with SVN" > /dev/null 2>&1; then
110
- echo " └─ ✅ Authenticated view (can see clone options)"
111
- fi
112
- else
113
- echo "❌ Cannot access"
114
- fi
115
-
116
- # Test creating a new repository page (requires authentication)
117
- echo -n "• New repo page: "
118
- NEW_REPO_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
119
- -H "Cookie: $COOKIES" \
120
- -H "User-Agent: Mozilla/5.0" \
121
- "https://github.com/new")
122
-
123
- if [ "$NEW_REPO_CODE" = "200" ]; then
124
- echo "✅ Can access (authenticated)"
125
- else
126
- echo "❌ Cannot access (HTTP $NEW_REPO_CODE)"
127
- fi
128
-
129
- echo ""
130
- echo "Testing private repository detection..."
131
- echo "───────────────────────────────────────"
132
-
133
- # Try to list repositories including private ones
134
- echo "Attempting to fetch repository list..."
135
-
136
- REPOS_PAGE=$(curl -s -L \
137
- -H "Cookie: $COOKIES" \
138
- -H "User-Agent: Mozilla/5.0" \
139
- "https://github.com/$USERNAME?tab=repositories")
140
-
141
- # Count repositories visible
142
- PUBLIC_COUNT=$(echo "$REPOS_PAGE" | grep -o 'itemprop="name codeRepository"' | wc -l | xargs)
143
- echo "• Repositories visible: $PUBLIC_COUNT"
144
-
145
- # Check if we can see private repo indicators
146
- if echo "$REPOS_PAGE" | grep -q "Private" > /dev/null 2>&1; then
147
- echo "• ✅ Can see private repository badges"
148
- PRIVATE_COUNT=$(echo "$REPOS_PAGE" | grep -o '>Private<' | wc -l | xargs)
149
- echo "• Private repositories visible: $PRIVATE_COUNT"
150
- else
151
- echo "• ⚠️ No private repository badges found (may not have any or not authenticated)"
152
- fi
153
-
154
- echo ""
155
- echo "Testing specific private repository (if you have one)..."
156
- echo "────────────────────────────────────────────────────────"
157
-
158
- # Function to test a specific private repo
159
- test_private_repo() {
160
- local repo_name=$1
161
- echo -n "• Testing $USERNAME/$repo_name: "
162
-
163
- REPO_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
164
- -H "Cookie: $COOKIES" \
165
- -H "User-Agent: Mozilla/5.0" \
166
- "https://github.com/$USERNAME/$repo_name")
167
-
168
- if [ "$REPO_CODE" = "200" ]; then
169
- echo "✅ Accessible (HTTP 200)"
170
-
171
- # Try to get file list
172
- FILE_LIST=$(curl -s \
173
- -H "Cookie: $COOKIES" \
174
- -H "User-Agent: Mozilla/5.0" \
175
- "https://github.com/$USERNAME/$repo_name" | grep -o 'js-navigation-open Link--primary' | wc -l | xargs)
176
-
177
- if [ "$FILE_LIST" -gt 0 ]; then
178
- echo " └─ ✅ Can see $FILE_LIST files/folders"
179
- fi
180
- return 0
181
- elif [ "$REPO_CODE" = "404" ]; then
182
- echo "❌ Not found or no access (HTTP 404)"
183
- return 1
184
- else
185
- echo "❌ Cannot access (HTTP $REPO_CODE)"
186
- return 1
187
- fi
188
- }
189
-
190
- # Test some common private repo names (you can modify these)
191
- echo "Testing potential private repositories..."
192
- for repo in "private" "personal" "dotfiles" "config" "secrets" "private-notes"; do
193
- test_private_repo "$repo"
194
- done
195
-
196
- echo ""
197
- echo "Testing raw file access..."
198
- echo "─────────────────────"
199
-
200
- # Try to access a raw file from a public repo (should work)
201
- echo -n "• Public repo raw file: "
202
- RAW_PUBLIC=$(curl -s -o /dev/null -w "%{http_code}" \
203
- -H "Cookie: $COOKIES" \
204
- -H "User-Agent: Mozilla/5.0" \
205
- "https://raw.githubusercontent.com/$USERNAME/get-cookie/main/README.md")
206
-
207
- if [ "$RAW_PUBLIC" = "200" ]; then
208
- echo "✅ Can access"
209
- else
210
- echo "❌ Cannot access (HTTP $RAW_PUBLIC)"
211
- fi
212
-
213
- echo ""
214
- echo "Advanced: Testing GitHub's auth state..."
215
- echo "────────────────────────────────────────"
216
-
217
- # Check the actual auth state from GitHub's perspective
218
- AUTH_CHECK=$(curl -s \
219
- -H "Cookie: $COOKIES" \
220
- -H "User-Agent: Mozilla/5.0" \
221
- -H "Accept: application/json" \
222
- "https://github.com/users/$USERNAME/hovercard" | jq -r '.message // "authenticated"')
223
-
224
- if [ "$AUTH_CHECK" = "authenticated" ]; then
225
- echo "✅ GitHub recognizes our session as authenticated"
226
- else
227
- echo "⚠️ GitHub response: $AUTH_CHECK"
228
- fi
229
-
230
- echo ""
231
- echo "Summary"
232
- echo "======="
233
- echo ""
234
- echo "📝 What we learned:"
235
- echo "• Browser cookies work for GitHub web pages (not API)"
236
- echo "• Can access authenticated pages like settings"
237
- echo "• Can view private repositories through the web interface"
238
- echo "• Cannot use these cookies for the REST API (needs tokens)"
239
- echo ""
240
- echo "💡 To actually work with private repos via CLI:"
241
- echo "• Use GitHub CLI: gh auth login"
242
- echo "• Or create a Personal Access Token"
243
- echo "• Browser cookies are mainly useful for web scraping"
244
- echo ""
245
- echo "✅ Test complete!"