Auth0 Home Blog Docs

Auth0 Lock for Swift: Allow user to use another Google account during next login


#1

So I’m using the Lock v2 widget for my iOS app and here’s the issue I’m currently encountering. I have only the social media login option enabled, with no login/password authentication available in the app. Here’s my current flow for log in/launch:

  1. Authentication token is meant to be kept in the system Keychain, if it’s not the app shows the Auth0 Lock widget on launch.
  2. User successfully authenticates via Lock widget using third party account (i.e. Google), then authentication token received via Lock is kept in the keychain and Lock is dismissed.
  3. As long as there’s access token available in the Keychain, the Lock widget is never presented.

To handle the logout I’m just removing the token information from the Keychain and presenting the Lock back again to the user. It’s also presented with each launch of the app, as there are no token information stored anymore. I’m not using any additional methods from the Lock API.

Problem is, that when the user logs out from the app and tries to log in again with the same provider it uses exactly the same third party account as before, meaning I cannot sign in with another Google account. It always forces me to use the same one, because it seems like the Lock widget still keeps the previous session.

I’m probably doing something wrong on the client side, so my question is - how should I address this issue to allow user sign in with account coming from the same third party provider?


#2

Take this with a grain of salt because my Swift skills are nil, but can you try this?:

Lock
  .classic()
  .withOptions {
    $0.parameters = ["prompt" : "select_account"]
  }

#3

Works flawlessly. Thanks a lot!