Is it possible to use bearer authentication for websocket upgrade requests?

前端 未结 3 617
半阙折子戏
半阙折子戏 2020-12-08 19:59

The upgrade request for opening a websocket connection is a standard HTTP request. On the server side, I can authenticate the request like any other. In my case, I would l

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 20:35

    You are right, it is impossible for now to use 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.

提交回复
热议问题