Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Sign In With Code

Discussion in 'Authentication' started by MiTschMR, Aug 24, 2023.

  1. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    With authentication version 3.0.0, sign in with code is now a thing. According to the roadmap, this can be used to sign in on a different device without the user needing to reauthenticate themselves. Still, I don’t quite see a use case with which this feature eases the pain of a reauthentication.

    What are your thoughts on this? Do you see more use cases for it?
     
  2. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    88
    Hi

    It will provide one more option for cross-platform games - especially when the targeted platforms do not support the same authentication providers.

    It really depends on the type of game you are developing and which platforms you are targeting.
     
    chengg_unity likes this.
  3. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    Thanks for the answer. I think I now understand it better. Though this would still mean that one would need to use a different platform for the initial sign-in and generating the code. The other platform would then use the ConfirmCodeAsync() and SignInWithCodeAsync() methods for the initial sign-in and SignInAnonymously() for the other upcoming sign-ins.
     
  4. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    I find the way of not being able to use the code directly in the SignInWithCodeAsync() method very frustrating, because it goes against all the other SignInWith* methods that are out there. Not sure what the idea behind first needing to confirm the code and then signing in was, but it introduces unnecessary complexity this way. It is also unclear from a public SDK perspective, how the system behind SignInWithCodeAsync() determines, what code to use. The one we just confirmed? Or does it make a call to the backend to get the latest code generated, maybe by another user?

    It is also unclear what the result of the ConfirmCodeAsync() call actually is, because there is no result returned. Only exceptions are thrown, but those are from a validation or connection perspective, they have nothing to do with the actual result.
     
  5. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    67
    Thank you for the early feedback, @MiTschMR !
    To provide some additional context, Sign In with Code further expands UGS' cross-platform support. For example, let's say a game is available on multiple platforms (eg. IOS, Android, Steam and Consoles). A player on IOS might want to sign in to Android, Steam or PlayStation. In this use case, the developer could implement Sign In With Code.

    1. A player generates a code from an unauthenticated device that they want to sign in. Let's say from PlayStation.
    2. The player enters the code in the authenticated device (IOS device) to confirm the code.
    3. After the successful confirmation, the player will be signed in on their PlayStation.

    This was not trivial to implement previously
     
    sandolkakos likes this.
  6. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    Okay, now I think I understand how it works.

    This is how I would do it then:
    1. The code is generated on the unauthenticated device and shown to the user
    2. The system will try to sign in (with polling presumably, makes the life easier) on the unauthenticated device
    3. An event is triggered on the authenticated device that a sign in code has been generated and shown to the user / User types in the generated code
    4. The code is confirmed on the authenticated device
    5. With the polling, the user signs in to the unauthenticated device
    Definitely missing the docs, but I guess I was way too early for them to be published :cool:
     
  7. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    67
    Yeah, you are right about the flow!
    The polling mechanism is supported. The authenticated device is not aware that a code has been generated from the unauthenticated device until the player types in the code.

    The doc will be available in the upcoming day(s). Cheers!
     
    sandolkakos, MousePods and MiTschMR like this.
  8. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    113
    Does the authentication device need to be a Unity app or can it come from a webpage using something like Clerk? @chengg_unity
     
  9. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454