11 Replies Latest reply on Mar 18, 2009 3:51 AM by selva_kumar

    Problem setting URLRequestHeaders on gdata call

      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);
      }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 )