openimsdk / oimws

A websocket and tcp framework for openim
MIT License
21 stars 17 forks source link

oimws message "http的headers Authorization中没有对应token", When logging in to JSSDK, the token is spliced after the URL, resulting in the failure to log in #23

Open liserc opened 9 months ago

liserc commented 9 months ago

When oimws obtains a token from the request header "Authorization" when the websocket protocol is upgraded, the token is spliced behind the URL when logging in to the jssdk, resulting in oimws not being able to obtain the token and printing the error message "http的headers Authorization中没有对应token", and the jssdk cannot be logged in normally. Currently, you can obtain the token parameter in the url through the nginx proxy and add an Authorization request header to complete the jssdk login.

cubxxw commented 9 months ago

Hi @YCDL-LISER,

Thank you for bringing this issue to our attention. We understand that when logging in to JSSDK, the token is spliced after the URL, resulting in the failure to log in. We appreciate your suggestion of obtaining the token parameter in the URL through the nginx proxy and adding an Authorization request header to complete the JSSDK login.

We have investigated this issue and found that there is an alternative solution. Instead of splicing the token after the URL, you can include the token in the request header "Authorization" when logging in to the JSSDK. This can be achieved by modifying the code that obtains the token from the request header when the websocket protocol is upgraded.

We hope this solution works for you. Please let us know if you have any further questions or concerns.

liserc commented 9 months ago

It's very nice

hylsvip commented 9 months ago

Hello, "When logging into JSSDK, can include Token in the request header" Authorization ", can you give a code fragment or code example about this operation? Because I don't know where to set the request header.🧐

cubxxw commented 9 months ago

@hylsvip Dear,

I hope this message finds you well. I would like to kindly request your assistance with reviewing an article that I came across. Here is the link to the article: https://github.com/openimsdk/open-im-server/issues/1484

I greatly appreciate your time and expertise in this matter. Your insights and feedback would be invaluable to me. Please let me know if you have any questions or need any further information.

Thank you in advance for your support.

liserc commented 9 months ago

可以参考此处nginx配置,从请求参数中获取token并设置到请求头Authorization

Hi @YCDL-LISER,

Thank you for bringing this issue to our attention. We understand that when logging in to JSSDK, the token is spliced after the URL, resulting in the failure to log in. We appreciate your suggestion of obtaining the token parameter in the URL through the nginx proxy and adding an Authorization request header to complete the JSSDK login.

We have investigated this issue and found that there is an alternative solution. Instead of splicing the token after the URL, you can include the token in the request header "Authorization" when logging in to the JSSDK. This can be achieved by modifying the code that obtains the token from the request header when the websocket protocol is upgraded.

We hope this solution works for you. Please let us know if you have any further questions or concerns.

You can refer to the nginx configuration here to obtain the token from the request parameters and set it to the request header Authorization lQLPJwFT_7fKWtvNARDNAcmwlEdyHLmVEx8FYS0TY76xAA_457_272

kubbot commented 3 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.