Skip to content

Auth Emulator and createSessionCookie /validDuration should be string #2770

@royletron

Description

@royletron

[REQUIRED] Environment info

firebase-tools:8.14.1

Platform:macOS

[REQUIRED] Test case

const expiresIn = 60 * 60 * 24 * 5 * 1000;
const idToken = '<TOKEN FOUND USING auth().currentUser.getIdToken() ON CLIENT>'
await auth().createSessionCookie(idToken, {
  expiresIn
});

[REQUIRED] Steps to reproduce

This is using firebase-admin on an express backed server, with a front end using firebase and firebase/auth. These are all connected to the firebase emulator running both firestore and the new auth. You'll need to get an ID token for a user (not sure if it has to be valid or not), and then pass this to the createSessionCookie example above. It should fail with the error Invalid JSON payload received. /validDuration should be string. This doesn't happen if I connect to a live Firebase project, only when using the emulator.

[REQUIRED] Expected behavior

That we receive a cookie that we can send back to the client.

[REQUIRED] Actual behavior

{ Error: An internal error has occurred. Raw server response: "{"error":{"code":400,"message":"Invalid JSON payload received. /validDuration should be string","errors":[{"message":"Invalid JSON payload received. /validDuration should be string","reason":"invalid","domain":"global"}],"status":"INVALID_ARGUMENT"}}"
     at FirebaseAuthError.FirebaseError [as constructor] (/Users/redacted-project-path/node_modules/firebase-admin/lib/utils/error.js:43:28)
     at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/Users/redacted-project-path/node_modules/firebase-admin/lib/utils/error.js:89:28)
     at new FirebaseAuthError (/Users/redacted-project-path/node_modules/firebase-admin/lib/utils/error.js:148:16)
     at Function.FirebaseAuthError.fromServerError (/Users/redacted-project-path/node_modules/firebase-admin/lib/utils/error.js:187:16)
     at /Users/redacted-project-path/node_modules/firebase-admin/lib/auth/auth-api-request.js:1510:49
     at process._tickCallback (internal/process/next_tick.js:68:7)
   errorInfo:
    { code: 'auth/internal-error',
      message:
       'An internal error has occurred. Raw server response: "{"error":{"code":400,"message":"Invalid JSON payload received. /validDuration should be string","errors":[{"message":"Invalid JSON payload received. /validDuration should be string","reason":"invalid","domain":"global"}],"status":"INVALID_ARGUMENT"}}"' },
   codePrefix: 'auth' }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions