Send login_hint with the device authorization request

Merged
JE
3mo ago
+53-3

RFC 8628 §3.1 lets a device client name the user it expects to approve the code (login_hint). Basecamp's device verification page is growing support for it, so basecamp auth login --login-hint <email> can steer a shared machine — or a person with several identities — to the right sign-in. The server never treats the hint as authentication; approval still comes from whoever holds the session.

What

  • oauth.WithDeviceLoginHint(hint) — a DeviceOption that adds login_hint to the device authorization POST. Unset leaves the form exactly as it was.
  • SPEC §16 requestDeviceAuthorization gains the optional loginHint? parameter, marked Go-only for now: no other SDK has a caller asking for it, and the option is additive, so parity can follow when one does.

Consumer

basecamp-cli wires --login-hint through LoginOptions.LoginHint and appends this option once it bumps to an SDK that carries it (basecamp/basecamp-cli — "auth login --with-token" PR).

Verification

  • cd go && go vet ./pkg/basecamp/oauth && go test ./pkg/basecamp/oauth — green. New TestRequestDeviceAuthorization_SendsLoginHintWhenSet covers both the sent form and the omitted-when-unset form.
  • gofmt -l clean. make lint did not run locally (golangci-lint on this machine predates the Go 1.27 export-data format and fails typecheck on every package, main included); CI's lint is the gate.

Summary by cubic

Adds oauth.WithDeviceLoginHint so oauth.RequestDeviceAuthorization can include Basecamp’s optional RFC 8628 login_hint, steering shared or multi-identity machines to the intended sign-in. Without the option, requests are unchanged; the hint never authenticates, and approval still comes from whoever holds the session.

Spec

  • Documents optional loginHint? support for device authorization and device login as Go-only until another SDK needs it.