启用针对Azure移动服务和Javascript客户端的SIgnalR身份验证 [英] Enabling Authentication with SIgnalR against Azure Mobile Services and a Javascript client

查看:51
本文介绍了启用针对Azure移动服务和Javascript客户端的SIgnalR身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚在使用JavaScript客户端时如何通过SignalR进行AMS身份验证.

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.

我下载了Azure移动服务的JavaScript客户端,我在AMS上安装了Signal R-一切已准备就绪,可以开始使用了.我已经有了身份验证设置.

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.

我实际上可以在AMS JS客户端上调用.login("microsoftaccount"),然后执行该过程并获取令牌和ID.

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.

我尝试仅调用$ .connection.hub.Start()-它给了我401.我尝试将令牌放入查询字符串,再次给了我401.我是否应该以某种方式通过SignalR调用登录函数?

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?

严重缺乏有关SignalR和AMS的文档,但是有人知道在哪里可能会对这种方法有什么解释吗?我的意思是带有SignalR的JavaScript客户端.

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.

谢谢

推荐答案

client.currentUser对象中定义了一个令牌-这是一个标准的JWT.完成后,将带有JWT值的标头X-ZUMO-AUTH添加到连接请求中.这将使用ASP.NET应用程序对请求进行身份验证.

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.

ZUMO的12天是一个很好的资源: http://www.thejoyofcode.com/The_twelve_days_of_ZUMO. aspx

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

这篇关于启用针对Azure移动服务和Javascript客户端的SIgnalR身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆