히스토리

  • [2026-01-21 Wed 22:18] 이거 매우 중요해.

관련메타

관련노트

Threads API 토큰 갱신 및 memex-kb Flake 전환

[2026-01-21 Wed 22:27]

배경

memex-kb 프로젝트의 Threads API 토큰이 만료되어 갱신 작업 진행. 기존 방법(User Token Generator)이 작동하지 않아 새로운 방법 발견.

핵심 발견: Graph API Explorer + threads.net API

토큰 발급 방법 (2026-01-21 검증)

  1. Graph API Explorer 접속

  2. 중요: 상단 드롭다운에서 API를 threads.net 으로 변경

    • 기본값은 graph.facebook.com 이라 작동 안 함
  3. “Generate Access Token” 클릭 → 단기 토큰 획득

  4. 장기 토큰(60일)으로 교환:

    nix develop --command python scripts/refresh_threads_token.py --exchange "단기토큰"

왜 User Token Generator는 안 됐나

  • 테스터 계정 매칭 문제
  • “Invalid Auth Code: Credentials entered do not match the selected tester profile”
  • Meta의 복잡한 계정 체계 (Facebook/Instagram/Threads)

memex-kb 개선 작업

1. Nix Flake 전환

shell.nixflake.nix 전환으로 빌드 속도 개선.

# 이전 (느림 - 매번 nixpkgs 평가)
nix-shell --run "python scripts/..."
 
# 이후 (빠름 - 캐싱)
nix develop --command python scripts/...

2. 토큰 갱신 스크립트 생성

scripts/refresh_threads_token.py 생성:

# 단기 → 장기 토큰 교환 (가장 많이 사용)
python refresh_threads_token.py --exchange "THAA..."
 
# 현재 토큰 테스트
python refresh_threads_token.py --test
 
# 기존 장기 토큰 갱신 (만료 전)
python refresh_threads_token.py

3. secretlint → gitleaks 교체

npm 의존성 제거, Nix로 통합.

# git repo 스캔
gitleaks detect
 
# 일반 파일 스캔 (디지털 가든 배포 전 검사용)
gitleaks detect --source=/path/to/files --no-git

4. direnv 연동

.envrc 추가로 디렉토리 진입 시 자동 환경 로드.

삭제된 파일

  • shell.nixflake.nix 로 대체
  • requirements.txtflake.nix 에서 Python 패키지 관리
  • package.json, package-lock.jsongitleaks 로 대체

스레드 내보내기 파이프라인

내보내기 명령

nix develop --command python scripts/threads_exporter.py --download-images

출력 위치

60일 후 갱신 체크리스트

[ ] 1. Graph API Explorer 접속
      https://developers.facebook.com/tools/explorer/1351795096326806/
[ ] 2. API를 "threads.net"으로 변경
[ ] 3. Generate Access Token → 단기 토큰 복사
[ ] 4. 장기 토큰 교환:
      nix develop --command python scripts/refresh_threads_token.py --exchange "토큰"
[ ] 5. 테스트:
      nix develop --command python scripts/refresh_threads_token.py --test

커밋

  • 커밋: 7007e92
  • 메시지: “refactor: Migrate to Nix flake and add Threads token refresh script”

관련 문서