Registration and authorization in the application

please tell me how to do the registration and authorization. On the site if you do it 's all clear , there is a simple connection to the database . But here's the first application that comes to mind is to make a site that will send the registration and the registration page to post a request with the login and password. The second option unsafe , make a connection to the database directly. It is also unclear to me how to make the user after login was always logged as presses the exit. Then I think you need to write a cookie file, for example plist. Explain please. If there are examples of this will be very cool!


  • CheesebaronCheesebaron DKInsider, University mod

    Due to language barriers I am not entirely sure if I understood your question. But you are asking about is authentication against some sort of Web Service. The best way to do this would be if you created a Web Service, which in some secure way allows you to send your credentials to it, to receive some kind of token back, which you then store on your phone. This could be OAuth, SWT or some other kind of authentication, there are loads of samples on the Internet on how to create a Web Service with those requirements.

    This Web Service should also expose the database, rather than connecting to it directly, preferably in some RESTful way. Again loads of samples exist, take a look at ServiceStack for example. Most of what you are asking is Web Server related, the calls to such a service is trivial and can be done with a simple call with HttpClient looking something like:

    using (var client = new HttpClient())
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("OAuth", "My Token");
        var msg = await client.GetAsync("");
        if (msg.IsSuccessStatusCode)
            var response = await msg.Content.ReadAsStringAsync();
            // do whatever with your response

    Your token can be stored in SharedPreferences, which there are several threads on this forum about.

    So what you need to do is to find some tutorials on Web Services, one possibility would be to use Parse or Azure Mobile for that. There are also several others you can use. When you get that fixed, come back and then we can help you with the phone client stuff.

Sign In or Register to comment.