title: Authenticate using only username and password with firestore in Android
body: <p>I'm new in android and firebase. I'm creating a quizz app where the user sign in or sign up ,and then the quizz starts. In the end, the score of the user and all the other are displayed in an ascending order. I want the user to sign up and sign in using only username and password.
  The project is connected to firebase. For now the user credentials in both sign in and sign up pages only gets stored in string variables.
  I want to use custom auth and firestore. I am following the official documentation <a href="https://firebase.google.com/docs/auth/android/custom-auth?authuser=0" rel="nofollow noreferrer">firebase.google.com/docs/auth/android/custom-auth?authuser=0</a> . I am confused with step 3 of Authenticate with Firebase. Do I take the credentials from the sign up form and send them to a authentication server like AuthO and it will give a token? Can you please tell what to do, in steps, right after I receive the credentials? I have set the security rule <code>allow read, write: if request.auth.uid != null;</code> for firestore. 
  Do i have to first connect it to firestore and store the credentials for authentication process and to use it in the end?</p>
  
  <p>It would be really helpful if code snippets are provided and links to helpful documents.</p>
  
  <p>The java file for sign in and sign up page are given below.</p>
  
  <p>Thank you.</p>
  
  <p>For sign in page</p>
  
  <pre><code>package com.guesstasif.guesswhat;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.content.Intent;
  import android.view.inputmethod.EditorInfo;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.view.KeyEvent;
  import android.widget.TextView.OnEditorActionListener;
  
  public class MainActivity extends AppCompatActivity {
  
  public static String name;
  public static String password;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
  
      EditText nameText = findViewById(R.id.nameText);
  
      nameText.setOnEditorActionListener(new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView nameText, int actionId, KeyEvent event) {
              boolean handled = false;
              if (actionId == EditorInfo.IME_ACTION_SEND || event.getKeyCode() == KeyEvent.KEYCODE_ENTER &amp;&amp; event.getAction() == KeyEvent.ACTION_DOWN) {
                  name = nameText.getText().toString();
                  handled = true;
              }
              return handled;
          }
      });
  
      EditText passwordText = findViewById(R.id.passwordText);
  
      passwordText.setOnEditorActionListener(new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView passwordText, int actionId, KeyEvent event) {
              boolean handled = false;
              if (actionId == EditorInfo.IME_ACTION_SEND || event.getKeyCode() == KeyEvent.KEYCODE_ENTER &amp;&amp; event.getAction() == KeyEvent.ACTION_DOWN) {
                  password = passwordText.getText().toString();
                  handled = true;
              }
              return handled;
          }
      });
  
  }
  
  //OnClick of Start button
  public void startQuizz(View view){
      Intent p1 = new Intent(this, qPage1.class);
      startActivity(p1);
  }
  
  //OnClick to register
  public void register(View view){
      Intent signup = new Intent(this, Signup.class);
      startActivity(signup);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>xml file for sign in page</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/sign_in"
  tools:context=".MainActivity"&gt;
  
  &lt;EditText
      android:id="@+id/nameText"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="181dp"
      android:width="300dp"
      android:backgroundTint="@color/colorPrimaryDark"
      android:hint="@string/name_input"
      android:imeActionId="10"
      android:imeOptions="actionSend"
      android:inputType="text"
      android:textColorLink="@color/colorPrimaryDark" /&gt;
  
  &lt;EditText
      android:id="@+id/passwordText"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="255dp"
      android:width="300dp"
      android:backgroundTint="@color/colorPrimaryDark"
      android:hint="Enter your password"
      android:imeActionId="10"
      android:imeOptions="actionSend"
      android:inputType="textPassword"
      android:textColorLink="@color/colorPrimaryDark" /&gt;
  
  &lt;Button
      android:id="@+id/start_button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="45dp"
      android:background="@color/colorPrimary"
      android:onClick="startQuizz"
      android:text="START"
      android:textColor="@android:color/background_light" /&gt;
  
  &lt;TextView
      android:id="@+id/registerText"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="140dp"
      android:clickable="true"
      android:onClick="register"
      android:text="Did not register?"
      android:textSize="24sp" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>For sign up page</p>
  
  <pre><code>package com.guesstasif.guesswhat;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.KeyEvent;
  import android.view.View;
  import android.view.inputmethod.EditorInfo;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.TextView.OnEditorActionListener;
  
  
  public class Signup extends AppCompatActivity {
  
  
      public static String signup_name;
      public static String signup_password;
      public static String signup_confirm_password;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_signup);
  
          EditText sign_up_nameText = findViewById(R.id.sign_up_nameText);
  
          sign_up_nameText.setOnEditorActionListener(new OnEditorActionListener() {
              @Override
              public boolean onEditorAction(TextView sign_up_nameText, int actionId, KeyEvent event) {
                  boolean handled = false;
                  if (actionId == EditorInfo.IME_ACTION_SEND || event.getKeyCode() == android.view.KeyEvent.KEYCODE_ENTER &amp;&amp; event.getAction() == android.view.KeyEvent.ACTION_DOWN) {
                      signup_name = sign_up_nameText.getText().toString();
                      handled = true;
                  }
                  return handled;
              }
          });
  
  
          EditText sign_up_passwordText = findViewById(R.id.sign_up_passwordText);
  
          sign_up_passwordText.setOnEditorActionListener(new OnEditorActionListener() {
              @Override
              public boolean onEditorAction(TextView sign_up_passwordText, int actionId, KeyEvent event) {
                  boolean handled = false;
                  if (actionId == EditorInfo.IME_ACTION_SEND || event.getKeyCode() == KeyEvent.KEYCODE_ENTER &amp;&amp; event.getAction() == KeyEvent.ACTION_DOWN) {
                      signup_password = sign_up_passwordText.getText().toString();
                      handled = true;
                  }
                  return handled;
              }
          });
  
          EditText sign_up_confirm_passwordText = findViewById(R.id.sign_up_confirm_passwordText);
  
          sign_up_confirm_passwordText.setOnEditorActionListener(new OnEditorActionListener() {
              @Override
              public boolean onEditorAction(TextView sign_up_confirm_passwordText, int actionId, KeyEvent event) {
                  boolean handled = false;
                  if (actionId == EditorInfo.IME_ACTION_SEND || event.getKeyCode() == KeyEvent.KEYCODE_ENTER &amp;&amp; event.getAction() == KeyEvent.ACTION_DOWN) {
                      signup_confirm_password = sign_up_confirm_passwordText.getText().toString();
                      handled = true;
                  }
                  return handled;
              }
          });
  
      }
  
      public void beginQuizz(View view){
          Intent p1 = new Intent(this, qPage1.class);
          startActivity(p1);
      }
  }
  </code></pre>
  
  <p>xml file for sing up</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/sign_in"
      tools:context=".Signup"&gt;
  
      &lt;EditText
          android:id="@+id/sign_up_nameText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="181dp"
          android:width="300dp"
          android:backgroundTint="@color/colorPrimaryDark"
          android:hint="@string/name_input"
          android:imeActionId="10"
          android:imeOptions="actionSend"
          android:inputType="text"
          android:textColorLink="@color/colorPrimaryDark" /&gt;
  
      &lt;EditText
          android:id="@+id/sign_up_passwordText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="251dp"
          android:width="300dp"
          android:backgroundTint="@color/colorPrimaryDark"
          android:hint="Enter new password"
          android:imeActionId="10"
          android:imeOptions="actionSend"
          android:inputType="textPassword"
          android:textColorLink="@color/colorPrimaryDark" /&gt;
  
      &lt;EditText
          android:id="@+id/sign_up_confirm_passwordText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="325dp"
          android:width="300dp"
          android:backgroundTint="@color/colorPrimaryDark"
          android:hint="Confirm password"
          android:imeActionId="10"
          android:imeOptions="actionSend"
          android:inputType="textPassword"
          android:textColorLink="@color/colorPrimaryDark" /&gt;
  
      &lt;Button
          android:id="@+id/Done_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="57dp"
          android:onClick="beginQuizz"
          android:text="Start" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>