Skip to content

Missing uid when using local emulator suiteΒ #411

@deen13

Description

@deen13

I'm currently trying to setup next.js authentication with this library and the firebase emulator suite. I had success connecting the next-firebase-auth with our cloud test instance but no success with the emulator. Every login attempt fails with an auth/argument-error where the uid is null.

Versions

next-firebase-auth version: ^0.14
Firebase JS SDK: ^8.9.1
Next.js: 12.0.7
Firebase Tools in Docker: 10.0.1

To Reproduce
Steps to reproduce the behavior:

  1. Setup Local Emulator Suite and Example Project
  2. Configure Emulator Suite
  3. Create firebase user using the emulator ui
  4. Attempt a login

The exception occurs when calling BaseAuth.createCustomToken.

BaseAuth.prototype.createCustomToken = function (uid, developerClaims) {
  return this.tokenGenerator.createCustomToken(uid, developerClaims);
};

Error

errorInfo: {
  code: 'auth/argument-error',
  message: '`uid` argument must be a non-empty string uid.'
}

Emulator Export

{
  "kind": "identitytoolkit#DownloadAccountResponse",
  "users": [
    {
      "uid": "5e9d49ecc652bf25ef18c461",
      "localId": "tjPIPI6VuxrhwNi5gKi8prsaJoRv",
      "createdAt": "1641059106748",
      "lastLoginAt": "1641059106748",
      "displayName": "John Doe",
      "photoUrl": "",
      "emailVerified": false,
      "email": "[email protected]",
      "salt": "fakeSalt1pE9Vg0uDz5b1JTNSNVA",
      "passwordHash": "fakeHash:salt=fakeSalt1pE9Vg0uDz5b1JTNSNVA:password=movement",
      "passwordUpdatedAt": 1641059106757,
      "validSince": "1641059106",
      "providerUserInfo": [
        {
          "providerId": "password",
          "email": "[email protected]",
          "federatedId": "[email protected]",
          "rawId": "[email protected]",
          "displayName": "John Doe",
          "photoUrl": ""
        }
      ],
      "customAttributes": "{\"role\": \"admin\"}",
      "lastRefreshAt": "2022-01-01T17:45:06.758Z"
    }
  ]
}

Environment

FIREBASE_CLIENT_EMAIL=<test-cloud-environment-mail>
NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=<test-cloud-environment-api-key>
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=<test-cloud-environment-domain>
NEXT_PUBLIC_FIREBASE_PROJECT_ID=movement-snacks-test

FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----......-----END PRIVATE KEY-----"

COOKIE_SECRET_CURRENT=someSecretValue
COOKIE_SECRET_PREVIOUS=anotherSecretValue

NEXT_PUBLIC_COOKIE_SECURE=false

FIREBASE_AUTH_EMULATOR_HOST="localhost:9099"

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions