【发布时间】:2013-04-27 13:52:44
【问题描述】:
我正在结合 Azure 移动服务构建我的 WP8 应用程序。 我使用 Twitter 作为 Azure 的身份验证方法。 所以我使用下面的代码登录:
user = await Client.LoginAsync(MobileServiceAuthenticationProvider.Twitter);
Client 是我的 MobileServiceClient。
执行时,这会触发 WebBrowser 打开并让用户登录等。 之后,“用户”对象被成功填充。 (.UserId)。
但是,我希望此登录只发生一次。因为用户下次打开应用需要重新登录。
另一个线程 (here) 中提到的建议建议我自己使用之前获得的数据构建用户对象,如下所示:
var mobileServiceClient = new MobileServiceClient("<your-app-url>", "<your-app-key>");
mobileServiceClient.CurrentUser = new MobileServiceUser("Foo:123456789");
mobileServiceClient.CurrentUser.MobileServiceAuthenticationToken = "<your-users-JWT>";
但这在 WP8 中是不可能的... MobileServiceUser 没有带有 1 个参数的构造函数,当构造一个空用户时,UserId 属性是只读的。而且 MobileServiceAuthenticationToken 不可用。所以这个方法行不通。
我与 Twitter 本身的身份验证工作,我通过 user.getIdentities 获得了 accessToken 和 accessTokenSecret,所以要清楚,问题是我的 azure 移动服务的用户身份验证..
还有其他建议吗? 提前致谢!
【问题讨论】:
-
这个问题你解决了吗?
标签: .net azure windows-phone-8 azure-mobile-services