0
votes

I am working on Xamarin cross platform app where I am implementing Google Sign on. From browser and postman, I am able to authticate and get user data using api. But when I am using in Xamarin forms webview, I am getting error of disallowed_useragent .

Because Google no longer supports webview request. So I need to set user agent in andriod as well as iOS app OR something to setup in PCL project that will be used by both platform.

I didn't find solution to solve this problem

Here is my code :

private async void LoginWithGoogle_Clicked(object sender, EventArgs e)
        {
            ShowLoader(true);


            var authRequest =
                  "https://accounts.google.com/o/oauth2/v2/auth"
                  + "?response_type=code"
                  + "&scope=email%20profile"
                  + "&redirect_uri=" + Constants.GoogleRedirectUri
                  + "&client_id=" + Constants.GoogleClientId;

            var webView = new WebView
            {
                Source = authRequest,
                HeightRequest = 1
            };

            webView.Navigated += WebViewOnNavigatedForGoogle;

            Content = webView;

            ShowLoader(false);
        }
1

1 Answers