AlistGo/alist · error

verify code failed: %s

Error message

verify code failed: %s

What it means

Second step of SMS login: the driver POSTs verification_id + verification_code to /v1/auth/verification/verify and throws when the response is an HTTP error, has an error field, or the returned VerificationToken is empty. The detail comes from accountErr (ErrorDesc, then Error, then response body).

Source

Thrown at drivers/guangyapan/driver.go:630

			return err
		}
	}

	var step2 verifyResp
	resp, err := d.accountClient.R().
		SetContext(ctx).
		SetBody(map[string]any{
			"verification_id":   verificationID,
			"verification_code": d.VerifyCode,
			"client_id":         d.ClientID,
		}).
		SetResult(&step2).
		Post("/v1/auth/verification/verify")
	if err != nil {
		return err
	}
	if resp.IsError() || step2.Error != "" || strings.TrimSpace(step2.VerificationToken) == "" {
		return fmt.Errorf("verify code failed: %s", d.accountErr(step2.ErrorDesc, step2.Error, resp))
	}

	var out tokenResp
	resp, err = d.accountClient.R().
		SetContext(ctx).
		SetBody(map[string]any{
			"verification_code":  d.VerifyCode,
			"verification_token": step2.VerificationToken,
			"username":           normalizePhoneE164(d.PhoneNumber),
			"client_id":          d.ClientID,
		}).
		SetResult(&out).
		Post("/v1/auth/signin")
	if err != nil {
		return err
	}
	if resp.IsError() || out.Error != "" || strings.TrimSpace(out.AccessToken) == "" {
		return fmt.Errorf("signin failed: %s", d.accountErr(out.ErrorDesc, out.Error, resp))

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Request a new SMS code and enter it promptly (complete the flow within its validity window).
  2. Ensure phone_number matches the number the SMS was sent to.
  3. If the error mentions captcha, let prepareSMSCode/ensureCaptchaToken refresh the captcha token and retry the whole login.
Defensive patterns

Strategy: validation

Validate before calling

// before attempting SMS login
if d.PhoneNumber == "" || d.VerifyCode == "" {
    return errors.New("phone_number and verify_code are both required for SMS login")
}
if len(d.VerifyCode) < 4 || !isAllDigits(d.VerifyCode) {
    return errors.New("verify_code looks malformed")
}

Try / catch

if err := d.loginBySMSCode(ctx); err != nil {
    if strings.Contains(err.Error(), "verify code failed") {
        // code is wrong/expired: get a NEW code, do not retry the same one
        return errors.New("SMS code rejected - request a new code and re-enter it")
    }
    return err
}

Prevention

When it happens

Trigger: loginBySMSCode runs with a wrong, expired, or already-used verify_code; the verification_id from prepareSMSCode expired; captcha requirement not satisfied; provider returns a non-2xx or an error payload.

Common situations: User reuses a one-time SMS code (the driver clears VerifyCode only after successful signin); too much time elapsed between requesting and submitting the code; the code was requested for a different phone number.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/6076e8647ff15de3. Report an issue: GitHub.