Enabling Authentication with SIgnalR against Azure Mobile Services and a Javascript client

最后都变了- 提交于 2019-12-22 11:17:00

问题


I am having a heck of a time trying to figure out how one is supposed to have AMS authentication with SignalR while using a JavaScript client.

I downloaded the JavaScript client for Azure Mobile Services, I've got Signal R on AMS - that's all hooked up and ready to go. I've got the authentication setup.

I can actually call .login("microsoftaccount") on the AMS JS client and go through that process and get back a token and id.

What I don't know is how to connect the two.

I tried just calling $.connection.hub.Start() - it gives me 401. I tried putting the token in the query string, again it gives me 401. Am I supposed to be calling a login function via SignalR somehow?

The documentation on SignalR and AMS is severely lacking but does anyone know where there might be some kind of explanation of how this is expected to work? JavaScript client with SignalR, I mean.

Thanks


回答1:


The client.currentUser object has a token defined in it - it's a standard JWT. Once you have that, add a header X-ZUMO-AUTH with the value of the JWT to the connection request. This will authenticate the request with the ASP.NET application.

A good resource is the 12 days of ZUMO: http://www.thejoyofcode.com/The_twelve_days_of_ZUMO.aspx



来源:https://stackoverflow.com/questions/26748715/enabling-authentication-with-signalr-against-azure-mobile-services-and-a-javascr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!