807648f Nov 1, 2016
@sebastianbenz @andreban @dandv
90 lines (79 sloc) 5.37 KB
<!-- #### Introduction
The [amp-access]( component adds support for paywalls and subscriptions to AMP, allowing the publisher to control which content is accessible by the reader and with what restrictions.
For sample `amp-access` server endpoints, see the [amp-publisher-sample]( project.
<!-- -->
<!doctype html>
<html ⚡>
<meta charset="utf-8">
<script async src=""></script>
<!-- #### Setup -->
<!-- Import the `amp-access` component in the header. -->
<script async custom-element="amp-access" src=""></script>
<!-- `amp-access` requires `amp-analytics` to be imported as well. -->
<script async custom-element="amp-analytics" src=""></script>
<!-- Optionally, use the [`amp-mustache`]( component to show text with values replaced from
the authorization response -->
<script async custom-template="amp-mustache" src=""></script>
<!-- Add the configuration for the `authorization`, `pingback` and the `login` endpoints. It is
also possible to create a fallback response that will be used if the authorization fails with the `authorizationFallbackResponse` attribute -->
<script id="amp-access" type="application/json">
"authorization": "",
"pingback": "",
"login": "",
"authorizationFallbackResponse": {
"error": true,
"access": false
<link rel="canonical" href="<%host%>/components/amp-access/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<!-- This section is visible to all users. No special markup is needed in this case.-->
<h3>The Article</h3>
This is a preview of the article.
<!-- Use the `amp-access` attribute to control the visibility of each component. The expression
must evaluate to a boolean value. If it evaluates to `TRUE`, the section will be shown. -->
<div amp-access="access">
<p>This section is visible to users if the authorization response contains: <code>"access": true</code>. This is usually the main content of the article.</p>
<!-- This section is only shown if the value of the `access` attribute on the response for
the authorization requests evaluates to `FALSE`-->
<div amp-access="NOT access">
<p>This section is only visible to users if the authorization response does not contain <code>access</code> or contains <code>"access": false</code>.</p>
<!-- It is possible to combine two values on the evaluation expression.
Check the docs to find out more about the [Expression Grammar](
<div amp-access="access AND NOT subscriber">
<p>This section is only visible to users with <code>"access": true</code> and <code>"subscriber": false</code></p>
<!-- Combine `amp-access` and `amp-mustache` to show information returned from the authorization request. In this case we show the number of free views left for non-subscribers. -->
<div amp-access="access AND views">
<template amp-access-template type="amp-mustache">
You are viewing article {{views}} of {{maxViews}} free articles this month!
<!-- Use `on="tap:amp-access.login"` to open the login dialog when the element is
`amp-access-hide` will default the component to be hidden and enabled later
if the `amp-access` expression is evaluated to `TRUE` -->
<div amp-access="NOT subscriber" amp-access-hide role="button" tabindex="0">
<a on="tap:amp-access.login">Login</a>
<!-- The logout link will only be shown for logged in subscribers. -->
<div amp-access="subscriber" amp-access-hide role="button" tabindex="0">
<a href="">Logout</a>
<!-- Checkout the [official amp-access sample]( for demos of first-click-free and view counting. -->