Link

Amp Subscriptions

The amp-subscriptions extensions implements the subscription-style access/paywall rules. There could be a local service or vendor services.

The properties in the “local” service are:

  1. authorizationUrl - the authorization endpoint URL. It is a credentialed CORS GET endpoint. AMP Runtime calls the endpoint before showing the story to the reader.
  2. pingbackUrl - the pingback endpoint URL. It is a credentialed CORS POST endpoint. AMP Runtime calls this endpoint automatically when the Reader has started viewing the story. One of the main jobs of the Pingback is for the Publisher to update metering information.

Important:

  1. The above endpoints need to be first party endpoints. So they need to be defined by the publisher server and inturn call below accesstype APIs with appropriate arguments.
  2. The pingback JSON object is sent with Content-type: text/plain. This is intentional as it removes the need for a CORS preflight check.


GET Authorization endpoint

Used to get meter and access details for a reader for a given story.

Arguments
story-id required
The unique identifier of the story which user is trying to read.
key required
The account key
readerId required
Unique identifier of a reader genereated by amp
accesstype_jwt optional
Used for logged in meter when the reader is logged in. This is the authorized user jwt
disable-meter optional
Needs to be sent as true for stories behind hard paywall. Such stories will not be metered and access will be granted only to subscribers.</a>
  $ curl -H 'X-SUBAUTH: <api-auth-key>'\
  -X GET 'https://accesstype.com/api/access/v1/stories/<story-id>/amp-access?readerId=<readerId>&key=<key>&accesstype_jwt=<accesstype_jwt>'
Returns

This returns a access grant object if the call succeeded.


POST Pingback endpoint

Arguments
story-id required
The unique identifier of the story which user is trying to read.
key required
The account key
readerId required
Unique identifier of a reader genereated by amp
accesstype_jwt optional
Used for logged in meter when the reader is logged in. This is the authorized user jwt
disable-meter optional
Needs to be sent as true for stories behind hard paywall. Such stories will not be metered and access will be granted only to subscribers.</a>

The request body is required to be same as the meter object.

  $ curl -H "Content-Type: text/plain" \
  -H 'X-SUBAUTH: <api-auth-key>' \
  -X POST 'https://accesstype.com/api/access/v1/stories/<story-id>/amp-pingback?readerId=<readerId>&key=<key>&accesstype_jwt=<accesstype_jwt> -d {
  "granted": true,
  "grantReason": "METERING",
  "data": {
    "numberRemaining": 6,
    "isLoggedIn": true
  }
}'
Returns

This returns a an empty object if the call succeeded.