osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Authenticating using URLRequest Issue


Hi

Either way, if this is running in the Flash Player and the remote URL has got a different domain name to where your SWF is running from, then it will request the cross-domain policy file. You might be able to see what's happening if you look at the "network" tab in your browser's development tools..

See e.g. https://stackoverflow.com/questions/2053530/how-can-i-make-a-https-call-using-httpservice-in-flex

cheers

   Andrew


-----Original Message-----
From: Deepak MS [mailto:megharajdeepak@xxxxxxxxx] 
Sent: 27 June 2018 05:36
To: users@xxxxxxxxxxxxxxx
Subject: [EXTERNAL] Re: Authenticating using URLRequest Issue

Any particular reason you want to use URLRequest?
You can easily do it using HttpService.

var hs: HttpService
hs.url = "your API"
hs.method = "POST"
hs.contentType = "application/json"
hs.send(JSON.encode(loginObject))

-Deepak


On Wed 27 Jun, 2018 7:29 am Tucsonjhall, <Jhall@xxxxxxxxxxxxxx> wrote:

> When I test with Postman authenticating at an API site, I get a return 
> token (which I need) fine. When I try in AS3, regardless of the 
> permutation I try, it returns the html of the page one would see if 
> they went to the post URL in a browser.
>
> One of the many permutations I've tried is:
>
> var loginJSON : String;
> loginObject = new Object();
> loginObject.username = "xxx@xxxxxxxxx"; loginObject.password = 
> "yyyyyyyyy"; loginJSON = JSON.stringify( loginObject );
>
> var loader : URLLoader = new URLLoader(); loader.addEventListener( 
> "complete", onLoginComplete, false, 0, true ); 
> loader.addEventListener( "ioError", onIOError, false, 0, true );
>
> var request : URLRequest = new URLRequest(); request.method = 
> URLRequestMethod.POST; request.contentType = "application/json"; 
> request.url = 
> "https://clicktime.symantec.com/a/1/u28tW_TDv-3Ko-VvSzagqc5gr0_TVdKHSo
> h34OCw9ck=?d=LAMcYc0GeCG5qmzxdDA6i2XRE7qUa4VYqY03k_j_z9sm7eOGU1BxnR7EW
> svo64tQtLqQMmicgxzaY68EGeJWtBjVB2Vf_KixbyWglckgGSaIm1XA_btYkV7OXMxHAvb
> fq3yXEGGdXGY8J1hzqYLB9ulrprmmUx9knnIp71T6jpdVBPublnoTKCkRtNtrMjlm32S0j
> 4WCVqj8E6YoJxtWPiNTXw3zgAhsyiSFSpMDdwEzPAFu-lHp5SPCAEHPL8KkNFUDZfrSun4
> dpgGtnMre57FdAPnYjM1_2Za3WJJXlSxt7rzyjLOhzvt8jhUAz--1CFM6aSMETiCuKyswb
> eZ38F--EC0zw6OfWhd_IyHTtTSMwPXJfXFdFsfDo6UcJCHpGcqZfEJsMJHqXHtsM7_gYQE
> IQRik1QmSMhu3ER0-ZU8pW8kEzVtnqOOwdTAYDDGXTLDEKyhk7hAt&u=https%3A%2F%2F
> xxx.xxxxxxx.com%2Fapi%2Faccess-token%2F";
> request.data = loginJSON;
>
> // Following taken out on this attempt // var header : 
> URLRequestHeader = new URLRequestHeader( "Content-Type", 
> "application/json" ); // request.requestHeaders.push( header );
>
> try {
>         loader.load( request );
> } catch ( e : Error ) {
>         Alert.show( "There was a problem communicating with LeagueLobster.
> Error
> message: " + e.name + " Code: " + e.errorID + " " + e.message ); }
>
> Does the server need to have a crossdomain.xml file or am I missing 
> something else that's obvious to more experienced programmers?
>
> Thanks much
>
>
>
> --
> Sent from: 
> https://clicktime.symantec.com/a/1/gO9zoMLDquBOeD3SQQvZ7-Ei-4Y-Q8xe55tZ86lJZiM=?d=LAMcYc0GeCG5qmzxdDA6i2XRE7qUa4VYqY03k_j_z9sm7eOGU1BxnR7EWsvo64tQtLqQMmicgxzaY68EGeJWtBjVB2Vf_KixbyWglckgGSaIm1XA_btYkV7OXMxHAvbfq3yXEGGdXGY8J1hzqYLB9ulrprmmUx9knnIp71T6jpdVBPublnoTKCkRtNtrMjlm32S0j4WCVqj8E6YoJxtWPiNTXw3zgAhsyiSFSpMDdwEzPAFu-lHp5SPCAEHPL8KkNFUDZfrSun4dpgGtnMre57FdAPnYjM1_2Za3WJJXlSxt7rzyjLOhzvt8jhUAz--1CFM6aSMETiCuKyswbeZ38F--EC0zw6OfWhd_IyHTtTSMwPXJfXFdFsfDo6UcJCHpGcqZfEJsMJHqXHtsM7_gYQEIQRik1QmSMhu3ER0-ZU8pW8kEzVtnqOOwdTAYDDGXTLDEKyhk7hAt&u=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F
>