Documentation / Integration guide / Part 4 of 18

4. The hand-off

The hand-off gives your server the reader that logged in on the subscription host. The code is ns_handoff. It lives 60 seconds and works 1 time.

  1. Read the value of the query ns_handoff on the request.
  2. Call POST /api/v1/handoff with the server key and {"code": "<value>"}.
  3. Norspire answers {"reader": "<token>", "maxAge": <seconds>}. Keep the token as opaque text.
  4. Set the reader cookie to the token with Max-Age of maxAge. Answer HTTP 303 to the same address with no ns_handoff.

The 7 middleware rules

A code that stays in the address of a page can give another party the reader on your site. Follow these 7 rules. The demo site and the runnable example in part 12 follow each rule.

  1. Run the middleware before routing on each GET request with ns_handoff in the query on your site origin. Run it on unmatched paths before 404 and on paths served by other apps behind the same origin.
  2. When the query holds more than 1 value of ns_handoff, read the last value. The real code is last.
  3. Call POST /api/v1/handoff with the 1-second budget of part 5. After HTTP 200, set the reader cookie with maxAge.
  4. After each other answer, after a timeout or a network error, and while the breaker of part 5 is open, set no cookie. While the breaker is open, call no exchange.
  5. In each case answer HTTP 303 to the same address. Remove each pair whose decoded name is ns_handoff, and keep each other pair as typed. Send Cache-Control: no-store. No page renders with ns_handoff in its address.
  6. A HEAD request with ns_handoff calls no exchange and gets the same HTTP 303.
  7. The breaker counts the server checks only. An exchange does not count in its window.

Your server sets the reader cookie. The embed reads no cookie and sets no cookie. If a CDN sits in front of your server, send each request with ns_handoff in the query to your server. Do not cache the 303. Do not cache a page with a Set-Cookie header.

1 log-in with a one-time hand-off code.

See also the API reference for POST /api/v1/handoff.