larksuite/cli · error

device code expired, please try again

Error message

device code expired, please try again

What it means

Terminal outcome sentinel of device-code registration: the code the user must scan expired before approval completed, so the poll loop ends. Kept distinct from explicit denial and from the client-side wait timeout so callers can give precise recovery hints.

Source

Thrown at internal/auth/app_registration.go:23

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"strings"
	"time"

	"github.com/larksuite/cli/internal/core"
)

// Terminal registration outcomes, exposed for typed classification by callers.
var (
	ErrRegistrationDenied   = errors.New("app registration denied by user")
	ErrRegistrationExpired  = errors.New("device code expired, please try again")
	ErrRegistrationTimedOut = errors.New("app registration timed out, please try again")
)

// Protocol defaults, mirroring the official SDK registration flow.
const (
	registrationBootstrapBrand = core.BrandFeishu
	defaultPollIntervalSeconds = 5
	defaultExpireInSeconds     = 600
	beginRequestTimeout        = 30 * time.Second
	maxPollIntervalSeconds     = 60
)

// normalizedInterval clamps a non-positive poll interval to the protocol default.
func normalizedInterval(v int) int {
	if v <= 0 {
		return defaultPollIntervalSeconds
	}
	return v

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Re-run `lark-cli config init --new` to get a fresh device code and complete the scan before it expires
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/auth/app_registration.go:23 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/9ecc43f450d28d05. Report an issue: GitHub.