2

I have a react-native app, a web api written in asp.net C# and a web app where i used forms authentication from asp.net. It checks the username and password stored in my db and sets cookie.

  1. What is the type of authentication i should follow?
  2. Can i use same forms authentication even in react-native. If yes then whats the approach.
  3. I want all the api calls to be made by authenticated users only. if not authenticated, then send back to login screen.
1
  • You can use OAuth2 to authenticate your user from your react native app to your asp.net api. Commented Aug 8, 2017 at 9:10

1 Answer 1

4
  1. You should follow a token based authentication, you can read more here

  2. The form authentication in react native as well as in standard native mobile or web application works the following way:

    • User types in his credentials in the application form
    • Your application takes his input data and sends it to a server to check the validity
    • If the credentials are valid, the server sends a unique TOKEN which you have to save in memory for additional ussage. This also means the user has successfully authenticated.
    • In every next http request, you have to pass the TOKEN a server sent before. In every request, server will check TOKEN validity, if it's valid, server will send data. Otherwise not.
  3. You have to setup your application state where you store user information. For example, once your server returns a TOKEN informing, you change your user's state to { loggedIn: true } Based on that value, you can navigate user to the corresponding screens such as Login or in app dashboard.

You can also check https://auth0.com/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.