Secure services with Adobe Air on Android

564
2
10-05-2011 10:35 PM
KarlMagnusson
New Contributor III
Hi!

I successfully managed to create an Adobe Air app with ArcGIS for Flex (picture attached:o). Much easier than I thought btw and it runs pretty well on 3G. Now I would like to connect to secure service in the app. My thought was to do according to this thread. But for what I know I need to get the IP address instead of "Web Application URL or HTTP Referrer" as identifier in the get token parameters. Am I right?  if yes, anyone know have to retrive the Ip-adress from andriods using Flex? Or should this be done in a complete other way?

thoughts on this is appreciated

Karl M
Växjö municipality, Sweden
Tags (2)
0 Kudos
2 Replies
KarlMagnusson
New Contributor III
Ok, this one I solved myself.
It was as easy as to type in "requestip" under clientid.
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);
    }
   }
0 Kudos
GiosiaPoma
New Contributor III
Hi, next time use a link to original source (original thread)
0 Kudos