2 Replies Latest reply on Nov 3, 2008 10:12 PM by Damon Edwards

    Problem setting URLRequestHeaders on gdata call

    curtisa2
      Hi,
      I'm trying to access google services from an AIR app via their gdata api.
      I'm able to authenticate via the gdata ClientLogin method (and confirm I get the all important 'auth' token which I need to supply on subsequent http GETs) but whenever I come to make those GETs I seem to be always either get a 401 (saying authorization is required) OR I get ..
      "Unable to load the requested document because of ArgumentError: Error #2096: The HTTP request header Authorization: cannot be set via ActionScript."

      My code is ..

      function getRequest(url,callback,session) {
      var loader = new air.URLLoader();
      var request = new air.URLRequest(url);
      request.method = "GET";

      request.requestHeaders = new Array();
      request.requestHeaders.push(new air.URLRequestHeader("Authorization", "GoogleLogin auth="+ session.authToken()));
      air.trace("ClientLogin token=" + session.authToken());

      air.trace("GET url is : " + url);
      request.manageCookies = false;
      loader.addEventListener(air.Event.COMPLETE, callback);
      loader.addEventListener(air.IOErrorEvent.IO_ERROR, ioError);
      loader.addEventListener(air.HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpStatus);
      loader.addEventListener(air.ProgressEvent.PROGRESS, progress);
      try{
      loader.load(request);
      }catch (error){
      air.trace("Unable to load the requested document because of " + error);
      }
      }

      I can see from the trace command that the right 'Auth' token is being applied.

      Am I using the wrong syntax for setting the headers or is there some security reason why this might be not be getting set ? Can anyone see what I'm doing wrong pls?
      (The google page I'm trying to follow to do this is http://code.google.com/apis/gdata/auth.html#ClientLogin )

      Thanks,
      Alex