AlexxIT/go2rtc · error

either email/password or refresh_token is required

Error message

either email/password or refresh_token is required

What it means

GET /api/ring requires exactly one authentication method: email/password OR refresh_token. This 400 branch is reached when the refresh_token query parameter was selected (non-empty via query.Get) yet is effectively empty at validation — i.e. the handler rejected the request because neither a usable email nor a refresh token was supplied. It is a request-validation error, not a Ring API error.

Solutions

  1. Provide a non-empty refresh_token: /api/ring?refresh_token=<token from a prior email/password login>
  2. Or provide email and password to start the login/2FA flow and obtain a refresh token
  3. Check the query parameter is spelled exactly refresh_token and is not empty
  4. Store the refresh token returned by go2rtc (URL field) for future automatic logins

Example fix

// before
/api/ring?refresh_token=
// after
/api/ring?refresh_token=eyJhbGciOi...
Defensive patterns

Strategy: validation

Validate before calling

if refreshToken == "" && email == "" {
    return errors.New("api/ring requires ?refresh_token=<token> or ?email=<email>&password=<pass>")
}

Try / catch

u, _ := url.Parse(ringAPIURL)
q := u.Query()
if q.Get("refresh_token") == "" && q.Get("email") == "" {
    return errors.New("ring source missing credentials")
}
// proceed with the request once a credential parameter is present

Prevention

When it happens

Trigger: Calling /api/ring with neither email nor refresh_token (hits the else branch with the sibling message), or with a refresh_token parameter that is present but blank/whitespace, or a misspelled parameter name (e.g. refresh= instead of refresh_token=).

Common situations: Forgotten to paste the refresh token; copying the URL with an empty refresh_token=; parameter name typos; clients stripping query values; expecting the endpoint to work with no credentials at all.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/e422991bb42ba991. Report an issue: GitHub.

Appendix: source

Thrown at internal/ring/ring.go:60

		}

		// Try authentication (this will trigger 2FA if needed)
		if _, err = ringAPI.GetAuth(code); err != nil {
			if ringAPI.Using2FA {
				// Return 2FA prompt
				api.ResponseJSON(w, map[string]interface{}{
					"needs_2fa": true,
					"prompt":    ringAPI.PromptFor2FA,
				})
				return
			}
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	} else if refreshToken := query.Get("refresh_token"); refreshToken != "" {
		// Refresh Token Flow
		if refreshToken == "" {
			http.Error(w, "either email/password or refresh_token is required", http.StatusBadRequest)
			return
		}

		var err error
		ringAPI, err = ring.NewRestClient(ring.RefreshTokenAuth{
			RefreshToken: refreshToken,
		}, nil)

		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	} else {
		http.Error(w, "either email/password or refresh token is required", http.StatusBadRequest)
		return
	}

	devices, err := ringAPI.FetchRingDevices()

View on GitHub (pinned to c245815e75)