The Flash Runtime PSDK needs a signed token to validate that you have the right to call the PSDK API on the domain where your application resides.
This class includes the loadFrom method which, when invoked, downloads the data stored at the specified URL (the token file) and tries to extract authorizedFeatures objects from it.
This step can vary. For example, you might want perform authentication before starting the application, or you might receive the token directly from your content management system (CMS).
This must be successful for your application to provide the required authorizedFeatures objects to the PSDK in the form of a MediaPlayerContext.
This example shows how you could use a single-token .xml file.
private function loadDirectTokenURL():void { var url:String = constructAuthorizedFeatureTokenURL(); _logger.debug("#onApplicationComplete Loading token from [{0}].", url); _authorizedFeatureHelper = new AuthorizedFeaturesHelper(); _authorizedFeatureHelper.addEventListener(Event.COMPLETE, onFeatureComplete); _authorizedFeatureHelper.addEventListener(ErrorEvent.ERROR, onFeatureError); _authorizedFeatureHelper.loadFrom(url); }
This example shows how you could use a multiple-token .swf file.
private function onApplicationComplete(event:FlexEvent):void { var url:String = constructAuthorizedFeatureTokenURLFromSwf(); _loader = new Loader(); var swfUrl:URLRequest = new URLRequest(url); var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, modEventHandler); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errEventHandler); _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); _loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtEventHandler); _logger.debug("# Loading token swf with context from [{0}].", url); _loader.load(swfUrl, loaderContext); } private function modEventHandler(e:Event):void { _logger.debug("loadSWF with domainID {0}", SecurityDomain.currentDomain.domainID); var loader : Loader = e.currentTarget.loader as Loader; var myAuthorizedTokensLoaderClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("AuthorizedTokensLoader") as Class; var myTokens:Object = new myAuthorizedTokensLoaderClass(); _authorizedFeatureHelper = new AuthorizedFeaturesHelper(); _authorizedFeatureHelper.addEventListener(Event.COMPLETE, onFeatureComplete); _authorizedFeatureHelper.addEventListener(ErrorEvent.ERROR, onFeatureError); var byteArray:ByteArray = myTokens.FetchToken(SecurityDomain.currentDomain.domainID); if (myTokens == null || byteArray == null || byteArray.length == 0) loadDirectTokenURL(); else { _logger.debug("token bytearry size {0}", byteArray.length); _authorizedFeatureHelper.loadFeatureFromData(byteArray); } _loader.unload(); }