auth0-flutter icon indicating copy to clipboard operation
auth0-flutter copied to clipboard

Create a new instance of Auth0 to use different login environment

Open tmorone-rezi opened this issue 1 year ago • 4 comments

Checklist

  • [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • [X] I have looked into the API documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

Our system has different Auth0 tenants for different environments: QA, Stage, Production We would like to re-initialize our auth0 client when the user selects a different environment. We currently do this, but discovered that Auth0 retains some settings from the first environment.

Example:

  • start app
  • select QA environment
  • logout
  • select Production environment
  • login

This all works until the access token expires. The call to renew the token goes to the QA environment instead of Production. There must be a singleton or something inside auth0 that does not get cleaned up when we re-initialize the environment.

Describe the ideal solution

Auth0 client should be able to fully dispose and allow the app to create a new instance.

Alternatives and current workarounds

No response

Additional context

No response

tmorone-rezi avatar Sep 18 '24 21:09 tmorone-rezi

Update: We're planning to support this as a part of the next major version that we're actively working on. The release is tentatively planned for mid Jan.

brth31 avatar Nov 27 '24 08:11 brth31

Update: We're planning to support this as a part of the next major version that we're actively working on. The release is tentatively planned for mid Jan.

Hi @brth31 . Thank you for your positive approach. We are facing the same issue and would be happy to hear from you when you have an update on the expected release date.

By the way, would it be possible to change storeKey when instantiating the CredentialsManager? In the Native code, we can specify the storeKey like this:

// ex. Auth0.swift

let authenticationX = Auth0.authentication(clientId: "aaaaa", domain: "x.example.com")
let credentialsManagerX = CredentialsManager(authentication: authenticationX, storeKey: "tenant-x")

let authenticationY = Auth0.authentication(clientId: "bbbbb", domain: "y.example.com")
let credentialsManagerY = CredentialsManager(authentication: authenticationY, storeKey: "tenant-y")

We use this function to connect to multiple tenants with a single app. We hope that Flutter SDK will also allow to change storeKey in this way.

shusuke0812 avatar Feb 25 '25 04:02 shusuke0812

@tmorone-rezi Are you observing this on both iOS and Android devices ? @shusuke0812 Will plan to add this as part of our upcoming release

pmathew92 avatar Feb 25 '25 09:02 pmathew92

@tmorone-rezi Are you observing this on both iOS and Android devices ? @shusuke0812 Will plan to add this as part of our upcoming release

Yes ios and android

tmorone-rezi avatar Mar 07 '25 19:03 tmorone-rezi

@brth31 would this also include signing with multiple accounts (on the same/different envs)?

Xylez01 avatar Apr 28 '25 13:04 Xylez01

@Xylez01 , Do you mean login with different user accounts on the same device, using the same or different tenant ?

pmathew92 avatar Apr 29 '25 10:04 pmathew92

@pmathew92 Ideally both. So different user accounts on the same device from either the same or different tenants.

Our app supports multi-account (mostly due to legacy) and internally we also have multiple environments, each with their own tenant I believe

Xylez01 avatar Apr 29 '25 17:04 Xylez01

@Xylez01 , thank you for clarifying that.

pmathew92 avatar Apr 30 '25 12:04 pmathew92