java - Authorization header is not receiving in the backend Angular 2 + Spring Boot -


i trying pass authorization header in http request :

my angular code this:

 let headers = new headers();         headers.append('content-type', 'application/json');         headers.append('authorization', this.urirequest.appendauthheadervalue());         let options = new requestoptions({ headers: headers });          console.log(json.stringify(options));          this.http.post(this.urlmanager.base_url + this.urlmanager.customerserviceurl, body, options).map(             (response) => {                 console.log(json.stringify(response));             }); 

on console can found in options authorization header getting set :

{"method":null,"headers":{"content-type":["application/json"],"authorization":["eyjhbgcioijiuziij9.eyjlehaioje1mdmyntq4ndisinn1yii6ild25ldyisinvzzxjjzci6imrlbw8ilcjyb2xlijoivfuij9.ovs69uweyib96mqlt61rqvyopnby0auhqpzuvhu40"]},"body":null,"url":null,"withcredentials":null,"responsetype":null} 

but in backend cannot able token:

my coros filer:

httpservletresponse res = (httpservletresponse) response;     httpservletrequest  req = (httpservletrequest) request;  res.setheader("access-control-allow-origin", "*"); res.setheader("access-control-allow-methods", "get, post, delete, put, options"); res.setheader("access-control-allow-headers", " x-requested-with, content-type, accept, accept-encoding, accept-language, host, referer, connection, user-agent, authorization, sw-useragent, sw-version"); res.setheader("access-control-expose-headers", "authorization");      // reply ok if request method options cors (pre-flight)     if ( req.getmethod().equals("options") ) {     res.setstatus(httpservletresponse.sc_ok);     return; }     chain.dofilter(request, response); 

i getting token this:

final string token = request.getheader("authorization"); 

please me on not able proceed here.

attached screen:

option: enter image description here

post:

enter image description here

response header: enter image description here

enter image description here


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -