public function RequestToken(username:String, password:String):void { var http:HTTPService = new HTTPService(); http.addEventListener( ResultEvent.RESULT, tokenResultHandler ); http.addEventListener( FaultEvent.FAULT, faultHandler ); // parameters for the request var param:Object = { "request" : "gettoken", "username": username, "password": password, "clientid" : "requestip", "expiration" : expir }; // prepare the httpService object for send the request http.url = "https://yourservername/arcgis/tokens?tokens"; // fake parameter ?tokens for start the process of token generation http.method = "POST"; // set POST method for not have problem in cache and logs http.resultFormat = "text"; http.request = param; // set parameters for the request http.send(); function faultHandler(event:FaultEvent):void { navigator.pushView(loginView); Alert.show(event.fault.toString()); } function tokenResultHandler(event:ResultEvent):void { var theToken:String = StringUtil.trim(event.result.toString()); // trim the generated token for surprise... loadProtectedMaps(theToken); } }
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.