Ras*_*sen 1 authentication facebook xamarin xamarin.forms
我正在使用Xamarin.Auth组件实现facebook登录.我请求我的后端登录(aspnet webapi),它返回一个挑战结果,我的应用程序重定向到facebook登录.在重定向的同时,我还在应用程序中弹出"服务器无效状态.可能伪造!" 在源代码中找到它https://github.com/xamarin/Xamarin.Auth/blob/master/src/Xamarin.Auth/OAuth2Authenticator.cs
如果我调查请求,我可以看到OAuth2Authenticator类中生成了一个状态.
我的问题是,在当前设置中处理身份验证的最佳方法,或者我应该避免让我自己的后端重定向应用程序登录.相反,让应用程序直接登录Facebook并将令牌从facebook发送到我的后端,我将通过调用https://graph.facebook.com/me验证它,然后生成我自己的auth_token,如果调用是有效?
我刚刚阅读Instagram登录文档https://www.instagram.com/developer/authentication/
而这正是我的意思,隐含或显性流动.对我而言,由于状态,明确不与Xamarin.Auth合作对抗facebook.
最好的祝福
这个游戏在这个游戏的后期不多,但我最近遇到了一个与我正在尝试连接的ASP.NET Web API同样的问题.
我最终做的是扩展OAuth2Authenticator课程和压倒一切OnPageEncountered().请参阅下面的Xamarin.Android实现:
public class DroidOAuth2Authenticator : OAuth2Authenticator
{
...
protected override void OnPageEncountered(Uri url, System.Collections.Generic.IDictionary<string, string> query, System.Collections.Generic.IDictionary<string, string> fragment)
{
// Remove state from dictionaries.
// We are ignoring request state forgery status
// as we're hitting an ASP.NET service which forwards
// to a third-party OAuth service itself
if (query.ContainsKey("state"))
{
query.Remove("state");
}
if (fragment.ContainsKey("state"))
{
fragment.Remove("state");
}
base.OnPageEncountered(url, query, fragment);
}
}
Run Code Online (Sandbox Code Playgroud)
当然,这会删除用户的安全警告,但不确定是否有任何其他方法.
| 归档时间: |
|
| 查看次数: |
530 次 |
| 最近记录: |