Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
5 contributors

Users who have contributed to this file

@dvoytenko @ed-bird @fstanis @ChrisAntaki @matthiasrohmer
161 lines (143 sloc) 4.45 KB
$category@ formats teaser
dynamic-content
websites
text
Implements subscription-style access protocol for Subscribe with Google.

amp-subscriptions-google

Implements subscription-style access protocol for Subscribe with Google.

Availability Beta.
Required Script <script async custom-element="amp-subscriptions-google" src="https://cdn.ampproject.org/v0/amp-subscriptions-google-0.1.js"></script>
Supported Layouts N/A

[TOC]

Introduction

The amp-subscriptions-google is the extension that enables Subscribe with Google in an AMP page.

See amp-subscriptions for more details on AMP Subscriptions.

See Subscribe with Google GitHub repo for details on the project itself.

Configuration

The amp-subscriptions-google is configured as part of amp-subscriptions configuration.

<head>
  ...
  <script async custom-element="amp-subscriptions"
  src="https://cdn.ampproject.org/v0/amp-subscriptions-0.1.js"></script>
  <script async custom-element="amp-subscriptions-google"
  src="https://cdn.ampproject.org/v0/amp-subscriptions-google-0.1.js"></script>
  <script type="application/json" id="amp-subscriptions">
  {
    "services": [
      {
        // Local service configuration
      },
      {
        "serviceId": "subscribe.google.com"
      }
    ]
  }
  </script>
</head>

Entitlements pingback

As described in amp-subscriptions, if a pingbackUrl is specified by the local service, the entitlements response returned by the "winning" service will be sent to the pingbackUrl via a POST request.

If subscribe.google.com is the "winning" service, the request to the pingbackUrl will be of the following format:

{
  "raw":"...",
  "source":"google",
  "service":"subscribe.google.com",
  "granted":true,
  "grantReason":"SUBSCRIBER",
  "data":{
    "source":"google",
    "products":[ ... ],
    "subscriptionToken":"..."
  }
}

Where data matches the entitlements response format.

Example with markup

<head>
  ...
  <script async custom-element="amp-subscriptions"
  src="https://cdn.ampproject.org/v0/amp-subscriptions-0.1.js"></script>
  <script async custom-element="amp-subscriptions-google"
  src="https://cdn.ampproject.org/v0/amp-subscriptions-google-0.1.js"></script>
  <script type="application/json" id="amp-subscriptions">
  {
    "services": [
      {
         // Local service configuration
        "authorizationUrl": "https://...",
        "pingbackUrl": "https://...",
        "actions":{
          "login": "https://...",
          "subscribe": "https://..."
        }
      },
      {
        "serviceId": "subscribe.google.com"
      }
    ]
  }
  </script>
  <script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "NewsArticle",
    {...},
    "isAccessibleForFree": "False",
    "publisher": {
      "@type": "Organization",
      "name": "The Norcal Tribune",
      "logo": {...}
    },
    "hasPart": {
      "@type": "WebPageElement",
      "isAccessibleForFree": "False",
      "cssSelector" : ".paywall"
    },
    "isPartOf": {
      "@type": ["CreativeWork", "Product"],
      "name" : "The Norcal Tribune",
      "productID": "norcal_tribune.com:basic"
    }
  }
  </script>
</head>
You can’t perform that action at this time.