none
Android client custom login Azure Mobile service (.NET Back end) RRS feed

  • Question

  • I am asking the same question here that I posted on StackOverFlow yesterday http://stackoverflow.com/questions/26048458/android-client-custom-login-azure-mobile-service-net-back-end

    have followed the steps in the following documentation http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-get-started-custom-authentication/ and built my .NET backend - I have been able to get the mobile service's new CustomRegistration and CustomLogin functions operational using the "try this out" button on the respective api pages at localhost:<portNumber>/help/Api/POST-api-CustomLogin and ../CustomRegistration. I have published these channges to the service to my azure mobile services.

    I am then attempting to connect to the service using an android app that I am building in Android Studio. I am very new to Android and as a result I'm having difficulty getting my app to use the CustomLogin provided by my mobile service. Below the code for the Android APP

    In the java/com.example.howzit folder:

    LoginResult.java

    package com.example.howzit;
    
    import com.google.gson.annotations.SerializedName;
    
    public class LoginResult {
    
        public String AuthenticationToken;
        //
        // Summary:
        //     Gets or sets the Microsoft.WindowsAzure.Mobile.Service.Security.LoginResultUser
        //     logged in.
        public LoginResultUser User;
    
    }


    LoginResultUser.java

    package com.example.howzit;
    
    import com.google.gson.annotations.SerializedName;
    
    public class LoginResultUser {
        public String UserId ;
    }
    LoginRequest.java
    package com.example.howzit;
        public class LoginRequest
        {
            public String username ;
            public String password ;
        }
    In the TodoActivity class I have this:
    mClient = new MobileServiceClient(
                        "https://mysite.azure-mobile.net/",
                        "APIKEY",
                        this).withFilter(new ProgressFilter())
                .withFilter(new RefreshTokenCacheFilter());
    
            LoginRequest loginUser = new LoginRequest();
                loginUser.username = "theUserName";
                loginUser.password = "thePassword";
    
                    mClient.invokeApi("CustomLogin",loginUser,LoginResult.class, new ApiOperationCallback<LoginResult>() {
                        @Override
                        public void  onCompleted(LoginResult result,Exception error, ServiceFilterResponse  response ){
                            if (error != null) {
                                        createAndShowDialog(error, "Error");
                                    }
                                    else {
                                        createAndShowDialog(result.User.UserId, "User");
                                    }
                        }
                    });


    I have debugged this and it basically hits the invokeApi call and continues to load the rest of the app never hitting the onCompleted routine...In Android Studio I have access to the LogCat, but there is nothing on there to inform me of an error. I'm really unable to get to the bottom of this. I have successfully implemented the Google login provider as well as the Window Azure provider, but am unable to with my own custom login. Any help would be greatly appreciated.

    more info:. I have set up remote debugging on VS2013 and if I remove the authentication and debug, break points are hit when using the android app, but the when using the Authentication the CustomLogin Post in the Controller is never hit.

    Friday, September 26, 2014 5:32 PM