auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BrowserLogin

func BrowserLogin() ([]*http.Cookie, error)

BrowserLogin opens a new browser window for the user to log in to Google.

func BuildCookieHeader

func BuildCookieHeader(cookies []*http.Cookie) string

BuildCookieHeader creates a Cookie header string like Python does: "SID=xxx; HSID=yyy; ..."

func ClearStorageState

func ClearStorageState() error

ClearStorageState removes the saved auth state.

func ExtractChromeCookies

func ExtractChromeCookies() ([]*http.Cookie, error)

ExtractChromeCookies reads Google cookies directly from Chrome's SQLite database. Does not launch Chrome, so it does not affect the existing login state. Works even while Chrome is running (read-only).

func LoadStorageState

func LoadStorageState() ([]*http.Cookie, error)

LoadStorageState loads cookies from a Playwright-format storage_state.json file. It checks NOTEBOOKLM_AUTH_JSON env var first, then falls back to the default path.

func SaveStorageState

func SaveStorageState(cookies []*http.Cookie) error

SaveStorageState saves cookies in Playwright-compatible format.

Types

type AuthTokens

type AuthTokens struct {
	Cookies   []*http.Cookie `json:"-"`
	CSRFToken string         `json:"csrf_token"` // SNlM0e value
	SessionID string         `json:"session_id"` // FdrFJe value
}

AuthTokens holds all authentication data needed for API calls.

func ExtractTokens

func ExtractTokens(cookies []*http.Cookie) (*AuthTokens, error)

ExtractTokens fetches the NotebookLM page and extracts CSRF token and session ID.

func (*AuthTokens) IsValid

func (a *AuthTokens) IsValid() bool

IsValid checks if the tokens appear to be usable.

type StorageCookie

type StorageCookie struct {
	Name     string  `json:"name"`
	Value    string  `json:"value"`
	Domain   string  `json:"domain"`
	Path     string  `json:"path"`
	Expires  float64 `json:"expires"`
	HTTPOnly bool    `json:"httpOnly"`
	Secure   bool    `json:"secure"`
	SameSite string  `json:"sameSite"`
}

type StorageState

type StorageState struct {
	Cookies []StorageCookie `json:"cookies"`
}

StorageState mirrors Playwright's storage_state.json format.

Jump to

Keyboard shortcuts

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