locked
Using Google API for Login in universal app leads the Windows 8 app run properly but not Windows Phone app

    Question

  • Hi,We have already developed a Windows 8.1 store app and now trying to converge the code for Windows Phone 8.1 by developing a universal app,convergence is found upto large extent but In windows 8.1 store app,we used Google API to login through Gmail ID which is giving exception

    "System.NotImplementedException: Not implemented     at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)  "

    This is the code:

           public async void Auth()
            {
                Windows.Storage.ApplicationData.Current.LocalSettings.Values["code"] = "";
                if (access_token == null)
                {
                    if (refreshToken == null && code == null)
                    {
                        try
                        {
                            String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id=" + Uri.EscapeDataString(clientID) + "&redirect_uri=" + Uri.EscapeDataString(callbackUrl) + "&response_type=code&scope=" + Uri.EscapeDataString(scope);

                            System.Uri StartUri = new Uri(GoogleURL);
                            // When using the desktop flow, the success code is displayed in the html title of this end uri
                            System.Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");

                            DebugPrint("Navigating to: " + GoogleURL);
                         
                                    WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                                                                            WebAuthenticationOptions.UseTitle,
                                                                            StartUri,
                                                                            EndUri);
                             
                            if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
                            {
                                string response = WebAuthenticationResult.ResponseData.ToString();
                                // strip to start of auth code

                                code = response.Substring(response.IndexOf("=") + 1);
                                Windows.Storage.ApplicationData.Current.LocalSettings.Values["code"] = code;
                                // TODO: switch off button, enable writes, etc.
                            }
                            else if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
                            {
                                //TODO: handle WebAuthenticationResult.ResponseErrorDetail.ToString()
                            }
                            else
                            {
                                ((GooglePlusLoginPage)renderArea).SendToLangingPage();
                                // This could be a response status of 400 / 401
                                // Could be really useful to print debugging information such as "Your applicationID is probably wrong"
                                //TODO: handle WebAuthenticationResult.ResponseStatus.ToString()
                            }
                        }
                        catch (Exception Error)
                        {

                            //
                            // Bad Parameter, SSL/TLS Errors and Network Unavailable errors are to be handled here.
                            //
                            DebugPrint(Error.ToString());
                            ((GooglePlusLoginPage)renderArea).SendToLangingPage();

                        }
                    }
                }
                codeToAcccesTok();
            }

    and In the line given below we are getting exception:

           WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                                                                            WebAuthenticationOptions.UseTitle,
                                                                            StartUri,
                                                                            EndUri);
                             


    Khushiiiiiiii

    Tuesday, August 12, 2014 6:17 AM

Answers

  • You'll have to follow Google API guidelines to get the WAB to work properly with their authentication system.  You may also want to check their forums for known issues.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, August 12, 2014 12:47 PM
    Moderator