Using Synacor authentication with AMP.
Implementation of Synacor authentication into AMP. The plugin can be implemented by providing a synacor
object in the player config:
var config = { plugins: { synacor: { resources: [ { src: "#{paths.plugins}synacor/Synacor.min.js", debug: "#{paths.plugins}synacor/Synacor.js", type: "text/javascript" } ], mvpd: { url: "//path_to_mvpd_endpoint", featured: [270, 268, 273], }, passive: false, service: "xyz", partner: "eyJlbnZpcm9ubWVudCI6Im1hdiJ9", display: { method: "redirect", heigth: 100, width: 200 }, transform: false } } }; akamai.amp.AMP.create("#akamai-media-player", config, function (event) { amp = event.player; amp.addTransform(akamai.amp.TransformType.MEDIA, { transform: function (media) { return bounce() .then(function (data) { // Provides a base64 encoded authN return amp.synacor.authenticate(data) }) .then(function (identity) { // Custom request return authz(identity.response) }) .then(function (data) { return amp.synacor.authorize(data) }) .then(function (authorization) { media.authorization = { key: "hdnea", token: authorization.securityToken } return media }) .catch(function () { amp.synacor.chooser() }) }, priority: 1 }) });