firebase-admin-python: Unable to create session cookie for tenant users

Hey everyone

I am setting up a python application and I would like to use firebase for authentication. For normal users the login flows works fine, my problem comes when I start using tenants.


When a user authenticates to my app, it gets a token and then, after verification, the token is exchanged for a long-lived session cookie. As mentioned before, this works great for normal users.

I am using the exact code described in the docs here: https://firebase.google.com/docs/auth/admin/manage-cookies#create_session_cookie

When I authenticate users that are part of a tenant though, I can’t find a way to convert their token into a session cookie.

I tried using session_cookie = auth.create_session_cookie(id_token, expires_in=expires_in, app=tenant_app) but I get always the same error message:

Error while calling Auth service (UNSUPPORTED_TENANT_OPERATION).

Am I missing something ? I am using the latest version of firebase-admin

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 3
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I created an issue to track the problem in the API: https://issuetracker.google.com/issues/204377229

Hey, All

I am experiencing the same issue using firebase-admin java client

also tried testing it using both https://cloud.google.com/identity-platform/docs/reference/rest/v1/projects/createSessionCookie and https://cloud.google.com/identity-platform/docs/reference/rest/v1/projects.tenants/createSessionCookie

in all cases I am getting

{
  "error": {
    "code": 400,
    "message": "UNSUPPORTED_TENANT_OPERATION",
    "errors": [
      {
        "message": "UNSUPPORTED_TENANT_OPERATION",
        "domain": "global",
        "reason": "invalid"
      }
    ]
  }
}

@hiranya911 Sorry to bother

I’ve tried different combinations from the web API Explorer but i always get the UNSUPPORTED_TENANT_OPERATION error. Since i can’t get the API call to succeed i am not sure how can I implement the function in code.

Can you please point me in the right direction?