My API Manager tool mandates that i should pass the Authorization Bearer access token with the websocket invocation call. They are providing samples of java code where they do that.
The bearer token is set like ("Authorization", "Bearer e2238f3a-e43c-3f54-a05a-dd2e4bd4631f") .How can i do that in javascript?
// HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline.
final WebSocketClientHandler handler = new WebSocketClientHandler(
WebSocketClientHandshakerFactory
.newHandshaker(uri, WebSocketVersion.V13, null,
false, new DefaultHttpHeaders()
.add("Authorization", "Bearer e2238f3a-e43c-3f54-a05a-dd2e4bd4631f")));
This is how they do it in java Is there a way like this to do it from my java script[Angular2] web application? How can i pass this from UI? Any Websocket bases testing tool can emulate this?
I found this answer here: https://stackoverflow.com/a/26123316/1715121
"It is impossible for now to use the Authentication header, because of the design of Javascript WebSocket API. More information can be found in this thread: HTTP headers in Websockets client API
However, Bearer authentication type allows a request parameter named "access_token": http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html#query-param This method is compatible with websocket connection."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With