chromeauth

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 39 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ReasonReadFailed 表示读取 Profile 的 Web Data 失败
	ReasonReadFailed = "read_failed"
	// ReasonNeedsReauth 表示 refresh token 不是 App-Bound 加密,需要在 Chrome 重新登录该账号
	ReasonNeedsReauth = "needs_reauth"
)

Variables

View Source
var ErrCredentialsRejected = errors.New("Chrome OAuth 续签材料被拒绝")

ErrCredentialsRejected 表示 OAuthMultilogin 以 INVALID_TOKENS 拒绝了保存的续签材料

Functions

func AccountID added in v0.1.3

func AccountID(email string) string

AccountID 返回邮箱对应的账号 ID

func DefaultChromeRoot added in v0.1.3

func DefaultChromeRoot() (string, error)

DefaultChromeRoot 返回本机 Chrome User Data 目录

func ImportCookies added in v0.1.3

func ImportCookies(ctx context.Context, options CookieImportOptions) (string, int, error)

ImportCookies 从 Cookie 文本生成账号状态,返回状态文件路径与模型数

func Refresh

func Refresh(ctx context.Context, material auth.OAuthMaterial, proxy string) ([]gemini.Cookie, error)

Refresh 使用已保存的 OAuth 续签材料重新签发 Google Cookie

func RemoteOrigin added in v0.1.3

func RemoteOrigin(raw string) (string, error)

RemoteOrigin 校验远程实例地址只含协议、主机与反向代理的子路径,非本机地址必须使用 HTTPS

func RunSetup

func RunSetup(ctx context.Context, args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer, interactive bool, servedAuth []string) error

RunSetup 执行账号配置,servedAuth 是同一数据目录中运行的服务使用的认证路径,没有服务在运行时为空

func ValidateProxy added in v0.1.3

func ValidateProxy(value string) (string, error)

ValidateProxy 校验 HTTP、HTTPS、SOCKS4 或 SOCKS5 代理 URL 并返回去掉空白的值

Types

type Account

type Account struct {
	Profile     string `json:"profile"`
	GaiaID      string `json:"-"`
	DisplayName string `json:"displayName"`
	Email       string `json:"email"`
	Importable  bool   `json:"importable"`
	// Reason 是账号不可导入的原因,不可导入且为空时表示该账号未在 Chrome 登录
	Reason string `json:"reason,omitempty"`
	// contains filtered or unexported fields
}

Account 描述本机 Chrome 中可发现的 Google 账号,同一 Profile 登录的每个账号各占一项

func Discover

func Discover(chromeRoot string) ([]Account, error)

Discover 只读列出本机 Chrome Google 账号

type Chrome added in v0.1.9

type Chrome struct {
	// contains filtered or unexported fields
}

Chrome 是一次读取的本机 Chrome 账号,多次导入共用账号发现结果与 App-Bound 主密钥

func OpenChrome added in v0.1.9

func OpenChrome(chromeRoot string) (*Chrome, error)

OpenChrome 发现 chromeRoot 中的 Google 账号

func (*Chrome) Accounts added in v0.1.9

func (c *Chrome) Accounts() []Account

Accounts 返回发现的账号

func (*Chrome) Import added in v0.1.9

func (c *Chrome) Import(ctx context.Context, options ImportOptions) ([]string, int, error)

Import 用 OAuth 续签材料为选中的账号生成协议账号状态,返回各状态文件的路径与模型数

type ChromeMaterial added in v0.1.6

type ChromeMaterial struct {
	Profile string
	// Encrypted 是 token_service 中的 refresh token 密文
	Encrypted []byte
	// contains filtered or unexported fields
}

ChromeMaterial 是本机 Chrome 中一个 Google 账号当前的续签材料

func FindChromeMaterial added in v0.1.6

func FindChromeMaterial(gaiaID string, profile string) (ChromeMaterial, error)

FindChromeMaterial 在本机 Chrome 中查找 Gaia ID 对应的可导入账号,同一账号登录多个 Profile 时优先 profile

func (ChromeMaterial) Decrypt added in v0.1.6

func (m ChromeMaterial) Decrypt() (auth.OAuthMaterial, error)

Decrypt 以 Chrome App-Bound 主密钥解密 refresh token,返回可保存的续签材料

type CookieAccount added in v0.1.7

type CookieAccount struct {
	AuthUser int    `json:"auth_user"`
	Email    string `json:"email"`
}

CookieAccount 是 Cookie 中一个已登录会话的账号:会话序号与登录邮箱

func DiscoverCookieAccounts added in v0.1.7

func DiscoverCookieAccounts(ctx context.Context, text string, proxy string, fallback string) ([]CookieAccount, error)

DiscoverCookieAccounts 依次以 Cookie 的各会话序号打开 Gemini 首页并读取登录邮箱,序号超出已登录的会话时首页回到已列出的账号或无法初始化,识别到此结束

type CookieImportOptions

type CookieImportOptions struct {
	Cookies string
	ID      string
	Output  string
	// Proxy 是写入账号的固定代理,RequestProxy 是没有固定代理时验证请求使用的代理
	Proxy        string
	RequestProxy string
	// AuthUser 是目标账号在浏览器多账号登录中的序号,即官网地址 /u/N 中的 N
	AuthUser int
}

CookieImportOptions 保存 Cookie 导入参数,Cookies 为 Cookie Header、浏览器导出的 JSON 或 Netscape cookies.txt

type ImportOptions

type ImportOptions struct {
	Output string
	// Proxy 是写入账号的固定代理,RequestProxy 是没有固定代理时导入请求使用的代理
	Proxy        string
	RequestProxy string
	Profiles     []string
	Emails       []string
}

ImportOptions 保存批量导入参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL