Search Unity

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

Official Authentication now support Username/Password!

Discussion in 'Authentication' started by chengg_unity, Aug 1, 2023.

  1. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    68
    Hello everyone,

    We are excited to announce that Username and Password support is now live with Authentication 2.7.2!

    Demo
    You can see it in action here:




    Documentation
    You can refer to our documentation (API and SDK) on how to set up and configure Username and Password.
     
    restush96, Tazyooo, Grizmu and 4 others like this.
  2. Tazyooo

    Tazyooo

    Joined:
    May 12, 2020
    Posts:
    8
    Hi,
    this demo looks very helpful to get more insights on best practices with the Authentication Package. Is it publicly available?

    Also, what happens if a user forgets his/her password? Is there any functionality to reset it? Are you planning on adding an email address recovery functionality or something similar?
     
    Last edited: Aug 4, 2023
  3. BregasSa

    BregasSa

    Joined:
    May 25, 2018
    Posts:
    3
    Updated to 2.7.2, but username & password method is not available yet. Any solution on this?


    edit: nevermind, the current docs seems wrong. the method is SignUpWithUsernamePasswordAsync, the docs wrote it as SignUpWithUsernamePassword without the 'Async' part.
     

    Attached Files:

    Last edited: Aug 9, 2023
    bugfinders likes this.
  4. BregasSa

    BregasSa

    Joined:
    May 25, 2018
    Posts:
    3
    Hi, Is there any solution when our player forget their password? I see that we can change password, but I don't see any option when player forget their password.
     
  5. WeanWind

    WeanWind

    Joined:
    Feb 14, 2023
    Posts:
    5
    Hello. What about gaming consoles like Xbox, will this auth method ever be supported on them? Do you have any plans about it?
     
  6. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    68
    Thank you so much for the feedback, I will follow up on the possibility to make it publicly available.
    Regarding password recover concern, it's not currently on our roadmap and it's up to the developer to assist in password reset for this scenario.
     
  7. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    68
    Authentication supports consoles. To get started, please open a support ticket here.
     
  8. Ynlay

    Ynlay

    Joined:
    Feb 17, 2019
    Posts:
    2
    Hey there I am trying this in the editor and when I try to sign up with SignUpWithUsernamePasswordAsync(username, password) I get the following error

    [Authentication]: Request failed: 400, {"title":"INVALID_USERNAME","detail":"Username does not match requirements. Insert only letters, digits and symbols among {., -, _, @}. With a minimum of 3 characters and a maximum of 20","details":[],"status":400}, request-id: ec7a7451-0eff-4703-940f-613ca9b963c9

    Now as far as I can tell my username is in fact correct since I also print my credentials on the console and have tried various combinations of usernames and passwords (all following the rules) and they all end up with the same result.
     
  9. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    Do you mind sharing a username that results in this error?
     
  10. Sparklmonkey

    Sparklmonkey

    Joined:
    Apr 1, 2020
    Posts:
    3
    Regarding this, how would the developer assist in resetting the password? Is there a tool in the Unity Dashboard?
     
    wgeorgio and Mahandal like this.
  11. wgeorgio

    wgeorgio

    Joined:
    Nov 15, 2017
    Posts:
    31
    I have created a tutorial on this and I found that I needed to be on Authentication 3.0 to get it to work correctly. Is there a way to keep the user signed in?
     
  12. israel_nftgco

    israel_nftgco

    Joined:
    Apr 27, 2023
    Posts:
    6
    Hi,

    We are thinking of switching to unity authentication (so far we have been using firebase), but we found two big limitations:
    1. Given a logged-in player, how can we know which providers he has linked? playerInfo.identities is always empty
    2. If a user has created an account using username/password, is there a way he can recover the password in case he forgot it?
     
  13. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    I don't use the Identities property but all the methods for getting the entries, like GetAppleID(), GetUnityID() etc. If I use GetUnityID() on a player that has a linked UPA account, then it is not empty. But for checking if a username/password is added I don't think there is a way for that.
     
  14. israel_nftgco

    israel_nftgco

    Joined:
    Apr 27, 2023
    Posts:
    6
    Well, that's a terrible workaround but it might work :D

    But what about "forgot password" feature, IMHO that's a pretty basic and fundamental feature.

    Also I miss other features such as confirmation emails, but I guess we can live without it
     
  15. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    Confirmation emails are sent when using UPA, but not for username/password, because a username is not necessarily an email. Email/password login is still an element on the authentication roadmap in the "Under Consideration" section: https://unity.com/roadmap/unity-gaming-services/game-backend
     
    wgeorgio likes this.
  16. wgeorgio

    wgeorgio

    Joined:
    Nov 15, 2017
    Posts:
    31
    According to scripting docs we have to use this method for signing up.
    SignUpWithUsernamePasswordAsync(String, String)
    In these docs it says something different. I believe the Sign In method is incorrect as well.
     
  17. MaxBackcountry

    MaxBackcountry

    Joined:
    Jan 24, 2014
    Posts:
    13
    Hi UNITY Team!

    Let me say first that anonymous authentication and authentication with a "game-specific" username and password are great ideas and we would love to implement this!

    But we did some testing (Editor 2022.3.10 and authentication package 3.0.0) and are confused:

    We are able to add a username/password to an anonymous/cached player. It also works fine to delete this "account" again.

    But what we cant do is sign in with this username / password as the method SignInWithUsernamePasswordAsync(String, String) is not accessible.

    That makes sense in so far as this method is not listed in the scripting API: https://docs.unity3d.com/Packages/c...es.Authentication.IAuthenticationService.html; However the method is described here in the manual: https://docs.unity.com/ugs/en-us/manual/authentication/manual/platform-signin-username-password).

    Now we ask ourselves: What's the point, if you can add a username / password account to a user, when you cannot come back and sign in to it? We thought th objective would be that a user can sign in on a different device that has not the same session token and can restore the cloud-saved game progress there by doing so.

    Could you please explain what we are missing?

    Thanks - Max
     
  18. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
    The option to sign in with username and password exists and is listed in the referenced API docs just before the
    SignOut
    method.
     
  19. israel_nftgco

    israel_nftgco

    Joined:
    Apr 27, 2023
    Posts:
    6
    Now, i ask again, whats the recommended procedure if a player forgets his password and/or username?
     
    bettywhite, MisfitVillager and pKallv like this.
  20. MaxBackcountry

    MaxBackcountry

    Joined:
    Jan 24, 2014
    Posts:
    13
    Well, ok it was kind of a typo. I just copied from the manual which reads "SignInWithUsernamePassword" instead of "SignInWithUsernamePasswordAsync"

    upload_2023-10-3_10-54-7.png

    In case you want to correct that...
     
    Last edited: Oct 3, 2023
  21. Tazyooo

    Tazyooo

    Joined:
    May 12, 2020
    Posts:
    8
    We currently do the following: There is a Neo4j DB in the background that saves user credentials. We also use a hashed version of the password rather than saving it in plaintext for the sake of data safety. In case a user forgets his/her password, they can contact us for manual password recovery.

    Unfortunately, we didnt find a better solution yet...

    Just keep checking the changelog regularly (https://docs.unity3d.com/Packages/com.unity.services.authentication@3.0/changelog/CHANGELOG.html), maybe Unity is already working on some new features regarding username/password
     
  22. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    it would be very epic if we get a method to check a token for validity in an easy way, imagine a multiplayer game where the dedicated server build whats to check if a user is logged in , because without that check everyone can claim to be logged in and the system is useless then
     
  23. P_e_t_a_c_h_e_k

    P_e_t_a_c_h_e_k

    Joined:
    Dec 26, 2017
    Posts:
    26
    still waiting
     
  24. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Anyone heard of any progress on the password recovery? Is there any API we have to at least reset it manually?
     
    bettywhite likes this.
  25. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    68
    Yes, you can use this admin api to reset a player's passport.
     
  26. gin1912

    gin1912

    Joined:
    Dec 20, 2023
    Posts:
    3
    How can I let players know that their username already exists when they're registering for a new account?
     
  27. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    454
  28. CH_Whyvern

    CH_Whyvern

    Joined:
    Nov 13, 2023
    Posts:
    1
    When I try to make a new account using username/password I get this error:

    WebRequestException: {"detail":"Username does not match requirements. Insert only letters, digits and symbols among {., -, _, @}. With a minimum of 3 characters and a maximum of 20","details":[],"status":400,"title":"INVALID_USERNAME"}

    If I Debug.Log the username I used it should be valid. But what's weird is if I manually input the strings into the SignUpWithUsernamePasswordAsync method using quotes it successfully creates the user. It also seems to be mainly the username that's causing the issue for me, since I'm able to use a password coming from a parameter as long as I input the username using a quote string. I also tried manually calling the API using http, but it also gave me the same error, but also worked when using quote strings.
    2.PNG 3.PNG
     
  29. sakshi_29

    sakshi_29

    Joined:
    Jun 20, 2023
    Posts:
    1
    Hi everyone,

    is there any method available to check if email or username already exists on Authentication cloud only then users can reset the password.
    Also, is there any other method available when user forgot the password then how to reset the password and update the new password on cloud.

    Thanks
    Sakshi
     
  30. anotherquest

    anotherquest

    Joined:
    Nov 15, 2023
    Posts:
    2
    I want to implement the following case:
    1. Sign in the player anonymously so the player can see his score in the leaderboard.
    2. If the player already has an account in Unity Player Accounts, he can sign in with his username and password.

    The issue is that when the player is already sign in anonymously, the call AuthenticationService.Instance.SignInWithUsernamePasswordAsync throws the error player already signed in.

    I can get the player score, sign out, call SignInWithUsernamePasswordAsync, once signed in update the score, but then the anonymous player score persists in the leaderboard.

    If I use AuthenticationService.Instance.AddUsernamePasswordAsync it will throw an error if the username and password are correct and if they are not, it will create a new account.

    Is it possible to sign in an anonymous player (not creating a new account with it) and not duplicate the score in the leaderboard?
     
    pKallv and wgeorgio like this.
  31. wgeorgio

    wgeorgio

    Joined:
    Nov 15, 2017
    Posts:
    31
    Is it possible after the user signs in for the first time and comes back, how can we have them be able to sign in automatically?
     
  32. wgeorgio

    wgeorgio

    Joined:
    Nov 15, 2017
    Posts:
    31
    I have been trying to figure out how to do this because the IsSignedIn method doesn't work for me either so I hope someone has an answer to this.
     
    pKallv likes this.