Azure移动服务 – 获取更多用户信息

我inheritance了用XAML编写的Windows 8应用程序。 所以在C#中,当我打这个电话

user = await MobileServices.MobileService .LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount); 

(这是Azure移动服务)

用户对象给我Token和MicrosoftAccount:…………..

为了得到authentication的人,我需要能够看到世卫组织正在请求访问…

我看下面的文章,但我似乎失去了一些东西? 这篇文章中的JavaScript是我必须在Node.js中写的东西吗?

示例文章: http : //blogs.msdn.com/b/carlosfigueira/archive/2013/12/12/expanded-login-scopes-in-azure-mobile-services.aspx

目前为了能够获得有关login用户的更多信息,您需要再次调用服务来检索用户信息。 您并不需要额外的login范围(您提到的post的主题)来检索用户名,因为这是所有提供者默认提供的。

这篇文章应该有你需要写在服务器端(node.js)的代码,以获得有关login用户的更多信息。 TL; DR版本如下:

在服务器端:添加这个自定义API(我将它称为“ userInfo ”;将GET的权限设置为“user”,所有其他人都设为admin):

 exports.get = function(request, response) { var user = request.user; user.getIdentities({ success: function(identities) { var accessToken = identities.microsoft.accessToken; var url = 'https://apis.live.net/v5.0/me/?method=GET&access_token=' + accessToken; var requestCallback = function (err, resp, body) { if (err || resp.statusCode !== 200) { console.error('Error sending data to the provider: ', err); response.send(statusCodes.INTERNAL_SERVER_ERROR, body); } else { try { var userData = JSON.parse(body); response.send(200, userData); } catch (ex) { console.error('Error parsing response from the provider API: ', ex); response.send(statusCodes.INTERNAL_SERVER_ERROR, ex); } } } var req = require('request'); var reqOptions = { uri: url, headers: { Accept: "application/json" } }; req(reqOptions, requestCallback); } }); } 

在客户端,成功login后,调用该API:

 user = await MobileServices.MobileService .LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount); var userInfo = await MobileServices.MobileService.InvokeApiAsync( "userInfo", HttpMethod.Get, null); 

userInfo将包含一个带有用户信息的JObject 。 在http://feedback.azure.com/forums/216254-mobile-services/suggestions/5211616-ability-to-intercept-the-login-response上有一个开放的function请求。