"Authorization" Header not supported in AS3 ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dabei
    New Member
    • Oct 2007
    • 4

    "Authorization" Header not supported in AS3 ?

    Hi, I am trying to use AS3 to make a URL request with authorization header. Using the code below:
    var request:URLRequ est = new URLRequest ( 'http://myserviceURL' );
    var requestHeader:U RLRequestHeader = new URLRequestHeade r("Authorizatio n", "AuthSub token=CI3xlrq1D xCjtruCAw");
    request.request Headers.push(re questHeader);
    ...

    But I get the following error:
    ArgumentError: Error #2096: The HTTP request header Authorization cannot be set via ActionScript.
    at flash.net::URLS tream/load()
    at flash.net::URLL oader/load()
    ...

    But according to adobe's api reference, "Authorizat ion" header should be allowed.
    Any ideas? Thanks!
  • emahe
    New Member
    • Jan 2008
    • 1

    #2
    Originally posted by dabei
    Hi, I am trying to use AS3 to make a URL request with authorization header. Using the code below:
    var request:URLRequ est = new URLRequest ( 'http://myserviceURL' );
    var requestHeader:U RLRequestHeader = new URLRequestHeade r("Authorizatio n", "AuthSub token=CI3xlrq1D xCjtruCAw");
    request.request Headers.push(re questHeader);
    ...

    But I get the following error:
    ArgumentError: Error #2096: The HTTP request header Authorization cannot be set via ActionScript.
    at flash.net::URLS tream/load()
    at flash.net::URLL oader/load()
    ...

    But according to adobe's api reference, "Authorizat ion" header should be allowed.
    Any ideas? Thanks!
    Hi,

    I currently encounter the same issue.
    I have found that the Authorization header was added to the disallowed HTTP headers list recently (after flash player r47)
    Did you find a workaround to make it work?

    Thx in advance,

    Eric

    Comment

    • mfharis
      New Member
      • Jan 2009
      • 1

      #3
      unable to set request header in as3

      hi all,

      I did face the similar issue and i cant set request headers in flash AS3. Actually i m trying to download file from S3 Amazon Bucket, which can only be allowed if custom header is set in a request. I m trying to set that but when I check the request Packets from Etheral or WireShark, the request doesnt contain any of mine custom header.

      here is my flash download code;

      var headers:Array = new Array();

      var authHeader:URLR equestHeader = new URLRequestHeade r("Authorizatio n","AWS: "+accesskey+":" +signature);
      var dateHeader:URLR equestHeader = new URLRequestHeade r("x-amz-date",date);

      request.url = domainUrl+objec tkey;
      request.method = URLRequestMetho d.GET;
      headers.push(au thHeader);
      headers.push(da teHeader);

      request.request Headers = headers;

      trace('request: '+request.reque stHeaders.lengt h);

      try {
      loader.load(req uest);
      }catch (error:Error) {
      trace("Unable to load requested document.");
      }

      Remember I uploaded crossdomain.xml in the bucket with polies mentioned as under;

      <cross-domain-policy>
      <allow-access-from domain="*" secure="false" />
      <site-control permitted-cross-domain-policies="all"/>
      <allow-http-request-headers-from domain="*" headers="*"/>
      </cross-domain-policy>


      In order to download file from Amazon Bukcet the Request Packet should be;

      GET /<bucketname>/<filename>HTT P/1.1
      x-flash-version: 10,0,2,54
      User-Agent: Shockwave Flash
      Host: s3.amazonaws.co m
      Authorization: AWS:<accesskey> :<signature>
      x-amz-date: <date>

      but after doing all the above work my final request sent to amazon;

      GET /<bucketname>/<filename>HTT P/1.1
      x-flash-version: 10,0,2,54
      User-Agent: Shockwave Flash
      Host: s3.amazonaws.co m


      :( no custom header here;
      plz can anyone suggests

      Comment

      • lionsign
        New Member
        • Nov 2008
        • 2

        #4
        mfharis: When I sent,

        Code:
        var protocol:String = (secure) ? "https" : "http";
        			var req:URLRequest = new URLRequest(protocol + "://" + AMAZON_ENDPOINT + resource);
        req.method = method;
        			var dateString:String = getDateString(new Date());
        var dateHeader:URLRequestHeader = new URLRequestHeader("Date", dateString);
        			var authHeader:URLRequestHeader = new URLRequestHeader("Authorization", getAuthenticationHeader(method, dateString, resource, contentType, hash));
        			req.requestHeaders.push(dateHeader);
        			req.requestHeaders.push(authHeader);
        
        var req1:URLRequest = getURLRequest("GET", "/" + escape(bucketName));                    
        				stream.load(req);
        throws Error #2096: The HTTP request header Date cannot be set via ActionScript.
        Please help someone to step forward.

        Comment

        • Fary4u
          Contributor
          • Jul 2007
          • 273

          #5
          i've got the same problem have you fix this ?

          Comment

          • lionsign
            New Member
            • Nov 2008
            • 2

            #6
            Authorization header is not supported by flash player. Have look of this http://help.adobe.com/en_US/FlashPla...estHeader.html

            Comment

            Working...