Xamarin.forms 如何修复xamarin表单中google身份验证中的403错误,以便在Android应用程序上访问web资源

Xamarin.forms 如何修复xamarin表单中google身份验证中的403错误,以便在Android应用程序上访问web资源,xamarin.forms,Xamarin.forms,提前谢谢 我在通过google身份验证连接到azure cloud应用程序时遇到此错误 “403.那是个错误。错误:disallowed\u useragent此用户代理不允许向google发出oauth授权请求,因为根据我们的策略,它被认证为嵌入式用户代理,只有浏览器才允许向google发出授权请求。我们为本机应用程序提供了多个库和示例,用于在浏览器中执行授权请求。” 如何修复此错误….这是去年发生的,因为Google的安全策略发生了变化。解决方法是使用Xamarin.Auth并在本机代码中使

提前谢谢

我在通过google身份验证连接到azure cloud应用程序时遇到此错误

“403.那是个错误。错误:disallowed\u useragent此用户代理不允许向google发出oauth授权请求,因为根据我们的策略,它被认证为嵌入式用户代理,只有浏览器才允许向google发出授权请求。我们为本机应用程序提供了多个库和示例,用于在浏览器中执行授权请求。”


如何修复此错误….

这是去年发生的,因为Google的安全策略发生了变化。解决方法是使用Xamarin.Auth并在本机代码中使用拦截器来捕获身份验证过程。下面的链接中提供了一个很好的示例

class ActivityCustomUrlSchemeInterceptor : Activity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        /* global::Android.Net.Uri uri_android = Intent.Data;

        //#if DEBUG
        //  System.Text.StringBuilder sb = new System.Text.StringBuilder();
        //  sb.AppendLine("ActivityCustomUrlSchemeInterceptor.OnCreate()");
        //  sb.Append("     uri_android = ").AppendLine(uri_android.ToString());
        //  System.Diagnostics.Debug.WriteLine(sb.ToString());
        //#endif

        // Convert iOS NSUrl to C#/netxf/BCL System.Uri - common API
        Uri uri_netfx = new Uri(uri_android.ToString());

        // load redirect_url Page
        AuthenticationState.Authenticator.OnPageLoading(uri_netfx);*/

        var uri = new Uri(Intent.Data.ToString());

        // Load redirectUrl page
        AuthenticationState.Authenticator.OnPageLoading(uri);

        this.Finish();

        return;
    }
}