This is integration issue. Your help is very appreciated


I have both Angular2 and Magento2 (bitnami) installed locally. Magento conf 
was changed to have the right headers (See below) for CROS.

I'm calling Magento2  from Angular2 to get the token and I'm getting the 
following issue:

*OPTIONS 
http://192.168.56.1:82/magento/index.php/rest/V1/integration/admin/token 
400 (Bad Request)*

*XMLHttpRequest cannot load 
http://192.168.56.1:82/magento/index.php/rest/V1/integration/admin/token. 
Response for preflight has invalid HTTP status code 400*

*EXCEPTION: Response with status: 0  for URL: null*

==================================================================================

*Angular 2 side:*

let headers = new Headers({'Content-type': 'application/json'});

 headers.append('Access-Control-Allow-Origin', '*');

 headers.append('Access-Control-Allow-Methods', 
'GET,POST,OPTIONS,PUT,DELETE');

 headers.append('Access-Control-Allow-Headers', 
'Origin,Authorization,X-Auth-Token,Accept,Content-Type');

 headers.append('Access-Control-Allow-Credentials', 'true'); 

 let options = new RequestOptions({ headers: headers });

return this.http.post( 
'http://192.168.56.1:82/magento/index.php/rest/V1/integration/admin/token',

                      JSON.stringify('{"username":"angUser", 
"password":"angUser2017"}'),

                      options)

                      .map(res => res.json());

 =================================

*Magento2*

angUser / angUser2017

Consumer Key:                                                 
5bhvi7gjvyafcp35rajuxh0y4me2plga

Consumer secret:                            yh1nefyw1u80rd0ip1q6f8pijv9x72f1

Access Token:                                   
g5plfwth2rhlwtuwfhhqp7mg6sebrxc3

Access Token Secret:                     i1f4t7j65oo8ydtnteub9xr7wrswe99c

 

*Magento headers:*

*1.       **Request URL:*

http://192.168.56.1:82/magento/index.php/?SID=ffego0i8jdeb0co3tt0perqta1

*2.       **Request Method:*

GET

*3.       **Status Code:*

200 OK

*4.       **Remote Address:*

192.168.56.1:82


2.       *Response Headers*

*1.       **Access-Control-Allow-Credentials:*

True

*2.       **Access-Control-Allow-Headers:*

Origin, Content-Type, Accept, Authorization

*3.       **Access-Control-Allow-Methods:*

GET,POST,OPTIONS,PUT,DELETE

*4.       **Access-Control-Allow-Origin:*

*

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to