Xamarin,Azure B2C,EF [英] Xamarin, Azure B2C, EF

查看:64
本文介绍了Xamarin,Azure B2C,EF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在周末停止工作,没有代码/配置更改。

My code stopped working on the weekend, there has been no code/config changes.

Xamarin Forms App使用  Microsoft.Identity.Client  1.1.4-preview0002进行登录,Azure移动应用服务与实体框架。

Xamarin Forms App using Microsoft.Identity.Client 1.1.4-preview0002 for login, Azure Mobile App Service with Entity Framework.

Xamarin登录代码

Xamarin Login Code

                    AuthenticationResult authenticationResult = await App.PCA.AcquireTokenAsync(Constants.Scopes,
                        GetUserByPolicy(App.PCA.Users, Constants.PolicySignUpSignIn), App.UiParent);

                    accessToken = authenticationResult.IdToken;

                // Log in to the mobile services
                var payload = new JObject();
                payload["access_token"] = accessToken;

                var user = await DataManager.DefaultManager.CurrentClient.LoginAsync(
                    MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory,
                    payload);


数据库访问的后端代码

var principal = this.User as ClaimsPrincipal;

string provider = principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;


上面的后端代码现在返回null,它返回通过以下方式登录的Azure B2C用户的oid Xamarin Forms app。

The above backend code now returns null, it was returning the oid of the Azure B2C user that was logged in via the Xamarin Forms app.

关于如何解决此问题的任何想法,我已尝试更新到Microsoft.Identity.Client Version =" 2.7.1",结果相同。

Any ideas on how to fix this, I have tried update to Microsoft.Identity.Client Version="2.7.1", with the same result.

谢谢,

J

推荐答案

你好vbl,

您可以调试代码并查看access_token的值是什么,如果值正确,则复制jwt令牌并转到" https ://jwt.ms/ "网站并检查"oid"对象标识符值。如果你有正确的
值,那么检查主体对象(var prinicipal = this.User为ClaimsPrincipal)。 

我认为当你传递有效负载时,响应(用户对象)是没有适当的信息。

Can you debug the code and see what's the value of access_token, if the value is correct, then copy the jwt token and go to "https://jwt.ms/" site and check "oid" object identifier value. If you have proper value then check the principal object (var prinicipal = this.User as ClaimsPrincipal). 
I think when you are passing the payload the response (user object) is not have proper information.

我希望这会有所帮助。


这篇关于Xamarin,Azure B2C,EF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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