- Home /
How to use already existing user credentials from my website as my applications login?
I have a website which has a login and a password for authentication. I have an android application built in Unity. I want to use the users login credentials of the user from my website to authenticate the users and they can get access to app.
Answer by Bunny83 · Nov 12, 2019 at 06:38 PM
Well, we have absolutely no idea how your user account system works on your site so it's up to you to implement the required API on your server.
Generally you want to have an API on your server where a client can simply send his username / password to and the serverside script would simply return a value to the client indicating if the password was correct or not. Since your "website" most likely uses HTTP or HTTPS you probably have some kind of serverside scripting support like PHP. So from Unity you simply use the UnityWebRequest class or the WWW class to communicate with your PHP script on your server.
We can't go much more into details since the serverside part is independent of Unity. Though in general here are some things you should consider:
Don't use GET parameters to pass your password and username to your script. Use a POST request and put the username and password as URL encoded values, JSON or any other format you can parse on the server into the request body.
Depending on where you host your server and what's your target user groups you may need to think about privacy and data security. It's generally adviced to use HTTPS with a proper SSL certificate on the server to avoid issues with data security.
In order to make it more difficult to crack your application you might want to include some additional challenge - response mechanism. So for example the client might generate a random number which is encrypted with a known public key and send alongside the credentials to the server. The server (which has the private key) can decrypt the number and send it back in the response. That way you can be sure you actually talk to your server and no MITM generating fake acknowledge responses.
Your answer
Follow this Question
Related Questions
How to add custom SSO (Single Sign On) login in Unity 3D application? 1 Answer
Login authentication on Unity 5 with php using xampp, and mysqli 0 Answers
Login to Steam from Android app 0 Answers
How to get unique token from Google Play login and Game Center Login 0 Answers
Login System using SQL with Registration on a Website 0 Answers