> For the complete documentation index, see [llms.txt](https://appscore.gitbook.io/authpair/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://appscore.gitbook.io/authpair/how-to/set-up-your-own-auth-url.md).

# Set up your own auth URL

## Step 1: Creating Firebase Project

Create your own Firebase Project on: <https://console.firebase.google.com/>

<figure><img src="/files/fevjfDUXpw3Pc7eEynS1" alt=""><figcaption></figcaption></figure>

## Step 2: Setting up Authentication

Add *"Authentication"* to your Project:

<figure><img src="/files/ayE7gvkMYpbPfYa7sTDa" alt=""><figcaption></figcaption></figure>

Add *"Anonymous"* (to retrieve pairing code) and at least one other sign-in method. We suggest *"Email/Password"* and *"Google"* sign in (as they don't need any extra step):

<div><figure><img src="/files/MCdtDFbXi4r8BmgDFWUz" alt=""><figcaption></figcaption></figure> <figure><img src="/files/aPtXFNFlPYmQheUYV5NA" alt=""><figcaption></figcaption></figure></div>

## Step 3: Setting up Realtime Database

Add *"Realtime Database"* to your Project:

<figure><img src="/files/5WKL5G21sVKmhh3YydmV" alt=""><figcaption></figcaption></figure>

Select Database Location and any security rule (we will change this in next step):

<div><figure><img src="/files/JjAXvOSGFW8L07aVIAzL" alt=""><figcaption></figcaption></figure> <figure><img src="/files/LBm7NT1FTOesKVdu8uHW" alt=""><figcaption></figcaption></figure></div>

Now switch to the *"Rules"* tab, paste the code below and click *"Publish"* (these rules ensure that users can only read/write their own data):

```
{
  "rules": {
    "users": {
    	"$user_id": {        
        ".write": "auth.uid == $user_id",
        ".read": "auth.uid == $user_id"
    	}
  	},
    "tokens": {
      ".write": "auth.token.email != null",
      "$code": { 
        ".write": "auth.uid.toLowerCase().beginsWith($code)",
        ".read": "auth.uid.toLowerCase().beginsWith($code)",
      }
    }
  }
}
```

<figure><img src="/files/osMlK4nPyvYGczjGgESN" alt=""><figcaption></figcaption></figure>

## Step 4: Host your Auth Page

Add *"Hosting"* to your Project:

<figure><img src="/files/bchTgbgDPfoEzGcnHquT" alt=""><figcaption></figcaption></figure>

Following the steps below to set up Firebase Hosting:

<div><figure><img src="/files/oSIGSDBtBLhFW8bNxOU0" alt=""><figcaption></figcaption></figure> <figure><img src="/files/d4ygaOVh11lltyZYwwrb" alt=""><figcaption></figcaption></figure> <figure><img src="/files/S1YlqW6JygvPVPiEpZr0" alt=""><figcaption></figcaption></figure></div>

Afterwards copy the *"index.html"* which is delivered with the AuthPair Unity package (in Web folder) to the currently created *"public"* folder:

<figure><img src="/files/otoNjxb2TaKtXo5L7xPA" alt=""><figcaption></figcaption></figure>

... and run `firebase deploy` in your command line to deploy the new index file.

Then you should find your own auth page on `https://[YOUR_PROJECT_ID].web.app`

<div><figure><img src="/files/EFUB8RbIBHDIShJK7qNd" alt=""><figcaption></figcaption></figure> <figure><img src="/files/tl8AVsViGyd1u286ky9m" alt=""><figcaption></figcaption></figure></div>

## Step 5: Link to your new Firebase Project

Finally open the AuthPair Demo scene in Unity or add the AuthPair prefab to your scene as described in [Get Started](/authpair/how-to/get-started.md)

Then copy the *"Realtime Database"* path and the *"API Key"* (from Firebase Project Settings) into the [Firebase Auth Script](/authpair/components/firebase-auth-script.md) (Settings in AuthPair prefab) as shown on the Screenshot below:

<div><figure><img src="/files/ap32YzoMDvC69tLD9ehF" alt=""><figcaption></figcaption></figure> <figure><img src="/files/e59mKTtlFJIDfvwGE1Tl" alt=""><figcaption></figcaption></figure> <figure><img src="/files/YI162vi2qbXiE2e7JaWl" alt=""><figcaption></figcaption></figure></div>

And change the URL of the *"AuthInstruction"* text to your own auth page: `https://[YOUR_PROJECT_ID].web.app`

<figure><img src="/files/IDf1Ul73dH2OJgRsNJAQ" alt=""><figcaption></figcaption></figure>

## The Result

Now run your Unity scene, klick *"Sign In",* enter the shown pairing code on your newly created auth page and click *"Connect Device"*.

You'll see that your Unity scene automatically logs in and the moving game objects are updating your Firebase Realtime Database every second:

<figure><img src="/files/0RjQZ4ZgmEtiCoPyOCHU" alt=""><figcaption><p>Game Objects and Texts are updating the Firebase Realtime Database</p></figcaption></figure>

If you stop and run the scene again, the objects and score will continue with the previous position and score since those values were saved in the database.

### Device Independent Storage

Because the object data (position, rotation, scale) and the text value is stored in the user account and not on the device, you now have a Device Independent Storage.

**That means, even if you run the app/game on another device you still have the same data** :tada:
