armin/open-ai-device-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

armin/open-ai-device-auth

Composer 安装命令:

composer require armin/open-ai-device-auth

包简介

OpenAI device code authentication CLI for ChatGPT tokens.

README 文档

README

Device Code authentication as a PHP Composer package. The CLI performs the OpenAI device login flow and writes an auth.json with ChatGPT tokens.

Requirements

  • PHP 8.4+
  • Composer
  • Device Code authentication enabled in your ChatGPT account

Installation

composer require armin/open-ai-device-auth

Usage

The CLI exposes three commands:

vendor/bin/open-ai-device-auth login
vendor/bin/open-ai-device-auth refresh
vendor/bin/open-ai-device-auth usage

Login

Start the device login flow:

vendor/bin/open-ai-device-auth login

Write to a custom location:

vendor/bin/open-ai-device-auth login --auth-file=/path/to/auth.json

Refresh

Refresh tokens in ./auth.json:

vendor/bin/open-ai-device-auth refresh

Refresh tokens in a custom auth.json:

vendor/bin/open-ai-device-auth refresh --auth-file=/path/to/auth.json

Usage

Fetch ChatGPT usage and rate limits from ./auth.json:

vendor/bin/open-ai-device-auth usage

Fetch ChatGPT usage and rate limits from a custom auth.json:

vendor/bin/open-ai-device-auth usage --auth-file=/path/to/auth.json

Return the raw payload as JSON:

vendor/bin/open-ai-device-auth usage --auth-file=/path/to/auth.json --format=json

Flow

  1. Run the login command.
  2. Open https://auth.openai.com/codex/device in any browser.
  3. Enter the displayed one-time code.
  4. Wait for authorization to complete.
  5. The CLI writes ./auth.json unless --auth-file is provided.

All three commands support --auth-file and -a. The default path is ./auth.json.

Output Format

{
  "auth_mode": "chatgpt",
  "OPENAI_API_KEY": null,
  "tokens": {
    "id_token": "...",
    "access_token": "...",
    "refresh_token": "...",
    "account_id": "..."
  },
  "last_refresh": "2026-04-24T11:17:48.681452Z"
}

Notes

  • The file format is tailored for ChatGPT token storage, not generic API key auth.
  • account_id is extracted from the returned id_token.
  • last_refresh is written as the current UTC timestamp when the file is created.
  • refresh replaces the stored tokens in-place and updates last_refresh.
  • usage reads the stored access_token and prints either a human-readable summary or JSON.

License

MIT

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固