Unity Player Accounts : Multi-Platform Auth Login (Google, Apple, Email & More!) in 9 Easy Minutes

Поділитися
Вставка
  • Опубліковано 11 жов 2024
  • 0:33 - Installing Authentication Package
    0:58 - Connect Project
    1:14 - Adding Player Accounts to Identity
    1:27 - Client ID from Dashboard
    1:40 - LoginController script
    3:26 - UILogin script
    6:40 -Testing
    6:55 - Google Login
    7:05 - Logged In
    7:21 - Exporting to android
    8:22 - Testing Android
    8:34 - Matching Ids
    Edit 5/2/2024
    Code used in the video:
    github.com/nav...
    Quick disclaimer:
    I usually don't use void with async methods but Unity has Action and UI methods that return void so Task would give error. I opted without Task.Run or anything since this is more focused on getting it working and its quicker this way.. If you're a c# veteran, don't cringe too hard :)
    Unity Player Accounts Docs
    docs.unity.com...
    Sorry for the audio loud keys :\

КОМЕНТАРІ • 80

  • @hansfritz6026
    @hansfritz6026 9 місяців тому +7

    nevermind i found the issue the code is not the problem during that setup phase in the unit dashboard i only selected ios/android but not PC. but if you dont select PC then testing on PC in the editor doesnt work. please continue this series its really helpful :-)

    • @navarone77
      @navarone77  9 місяців тому

      Interesting find
      Good to know this for future, glad you got it all sorted!
      Happy Coding :)

    • @RELIM_RO
      @RELIM_RO 8 місяців тому

      Thank you brother, was about to post something about it. then I read your comment and face palmed myself so hard XD.

  • @lucasalmeida240
    @lucasalmeida240 Місяць тому +1

    Excellent video, could you make one using Play Games as a Provider? I saw that there are several options besides this one, but I couldn't adjust the code to use with Play Games... Thanks!

  • @SelaMalka
    @SelaMalka 7 місяців тому +2

    Thank you very much! great tutorial!
    One question though - can you think of a way to keep the player logged in even after he quit the application?

    • @navarone77
      @navarone77  7 місяців тому +1

      Do you mean on the mobile device ?

  • @hardworkerstudio
    @hardworkerstudio 7 місяців тому +1

    it really difficult to follow your typing,
    some class are missing some class are don't know what namespace you used,
    you should add all script to description,
    so, people can easily copy them

    • @navarone77
      @navarone77  7 місяців тому

      Sorry you had troubles, not sure classes were missing.
      Okay I will add all the scripts to description

  • @javiergarcialopez8365
    @javiergarcialopez8365 9 місяців тому +3

    Nice tutorial bro !! Thanks so much !!!

    • @navarone77
      @navarone77  9 місяців тому

      you're welcome :)
      thanks for watching!

  • @goncalobarros4124
    @goncalobarros4124 24 дні тому

    I did this and it is working. Now, all of the sudden the login when redirects me to unity log in on the browser gives "OOPPS Something is wrong!try to signing in again" Do you know what is happening?

  • @hansfritz6026
    @hansfritz6026 9 місяців тому +2

    unfortunatly im getting "error_description=The+request+is+missing+a+required+parameter+or+is+using+an+unsupported+parameter."

    • @navarone77
      @navarone77  5 місяців тому

      Hi sorry for late reply, are you still having this issue? I wouldn't mind taking a look into it again, you'd have to provide me more detail on what going on or where is exactly that error appears.
      thanks!

  • @12Kefu
    @12Kefu 4 місяці тому +2

    hey the code is great but you have to login every time you launch the app can you help me with the issue

    • @navarone77
      @navarone77  4 місяці тому

      You can make a system easily, after you login , you can use the method for detecting already cached player, using the method below
      docs.unity.com/ugs/en-us/manual/authentication/manual/cached-players

  • @ROCKSMASHER
    @ROCKSMASHER Місяць тому

    Can you please tell how can we make that it will be saved in user like instead of signing in everytime it should be remember me and logout buttons

  • @hardworkerstudio
    @hardworkerstudio 7 місяців тому +1

    I feel thank you for making this VDO a bit
    But!!!
    why do you add functions to Buttons by scripts?
    this is you are making a Tutorial VDO,
    and your typing is also very difficult to follow
    something should add first, But you add last, it so wiered
    and it not makesense at all!

    • @navarone77
      @navarone77  7 місяців тому +1

      Thank you for the feedback, I'll certainly make note of your suggestion about the order of elements in the video. Is there a specific part this occurs?
      I'll review and adjust accordingly for future content.
      Regarding the buttons,assigning them in code for better clarity. It's definitely helpful to have all references visible in the code editor for easier management and understanding what is linked to what without going through inspector or unity Editor every time. Thanks again for your insights!

  • @devonn6_
    @devonn6_ 8 місяців тому +1

    It works fine on editor but on phone the app restarts again and goes to he login page...Any solutions

    • @navarone77
      @navarone77  7 місяців тому

      I tested on phone as you see in video and seems to work , would you mind sharing more info on your setup ?

    • @devonn6_
      @devonn6_ 7 місяців тому

      @@navarone77 yes..but let me try one more time...

    • @devonn6_
      @devonn6_ 7 місяців тому

      @@navarone77 one think I want to say that when I click on login it will open a browser and try to login..but when it goes back after login from the browser ...the game will restart ..its seems its not running on background. .any solution ?

    • @navarone77
      @navarone77  7 місяців тому

      @@devonn6_ hmm that is strange, something might be wrong with your code I'm thinking. Just tested everything again and seems to work here. Perhaps try it on a brand new project just to test out?

    • @devonn6_
      @devonn6_ 7 місяців тому

      @@navarone77 we need to write code for making our app run on recent background apps?..

  • @fastsolution
    @fastsolution 7 місяців тому

    did they removed the "unity player accounts" i cant see it in the services ?

    • @navarone77
      @navarone77  7 місяців тому

      Did you install the Authentication package ?
      Just tested it on Unity 2023 as well, it is still there in Project Settings after you install Authentication.

    • @fastsolution
      @fastsolution 7 місяців тому

      @@navarone77 yes i did but player accounts is not showing in services it shows online in the providers.. could it be the unity version issue ? i am using 2022.1.24f1

    • @fastsolution
      @fastsolution 7 місяців тому

      it shows all the other providers like facebook,google,steam etc..
      @@navarone77

    • @Nounsi_Dev
      @Nounsi_Dev 7 місяців тому

      @@fastsolution restart the editor, atleast that how i sovle the issue

    • @MarwanSharaiha
      @MarwanSharaiha 5 місяців тому

      @@Nounsi_Dev it can only be selected in Unity Cloud and then it reflects automatically in the Authentication tab.

  • @hansfritz6026
    @hansfritz6026 9 місяців тому +1

    would you mind including this in your next video ? ugs/manual/authentication/manual/best-practices this includes first time user experience which i am struggling right now. i want a anonymous login in the background and a check for cached user and then later offer the player a UI popup with the offer of linking with an actual google or apple account

    • @navarone77
      @navarone77  9 місяців тому +1

      Prefect timing! I am actually working on a series on this Unity system, that also includes doing Player Profiles, chat features and also game avatars ofc :)
      I'll be sure to drop the video with your suggestions first, thanks for reminder! if you haven't already, don't forget to subscribe and stay tuned

    • @lawrence_g3
      @lawrence_g3 26 днів тому

      @@navarone77 hey I love your tutorials and I am really looking forward to this specific topic. Please keep us updated. I have liked and subscribed with notifications on!

  • @lukeydzbecx8319
    @lukeydzbecx8319 9 місяців тому +2

    Bro thank u for this

  • @indievisualgames345
    @indievisualgames345 8 місяців тому

    Hi nice tutorial, Is there any way to have multi login methods for Google Apple and custom login, also in that case how the auto login will check in terms of scripting, eg a user has apple login, if google play login fails in auth then how it will come to apple login and check via scripting. on the login screen we have 3 ways to login that is google apple & custom email login

    • @navarone77
      @navarone77  8 місяців тому

      Do you mean separately ?
      Google play by the way is a separate auth , this one is the Unity Player Login should cover all those mentioned already in vid. The Player Login method only waits for the token once logged in.
      Would you mind explaining the use case of what you're doing this for?

  • @jacobjacob5735
    @jacobjacob5735 6 місяців тому +2

    Why did you not upload the code? At least write it in the description or as a comment. Without comment and then also sped up. Not really as helpfull as I had hoped...

    • @navarone77
      @navarone77  5 місяців тому

      It's pretty straight forward, but I can see how it can be useful to have source code. I will do so in the next videos.
      Appreciate the Feedback

    • @AsTrO-zq1kz
      @AsTrO-zq1kz 5 місяців тому +1

      ​@@navarone77bro pls reply. So,If we use this login system,this can save the in-game data for each account for example,the level of player or something they have collected?And once they logout and then login again ,may the data be saved for that account.?

    • @TheCollectiveYoutube
      @TheCollectiveYoutube 5 місяців тому +1

      ​@@AsTrO-zq1kz yes, but you use learn how to read and write to the database

    • @navarone77
      @navarone77  5 місяців тому +1

      @@AsTrO-zq1kz That is correct, this allows to store data for each one of those player accounts via Unity Cloud Save.
      I have an intro video on intro to Cloud Save , working on a series to do dashboard for players to manage their own data.
      Subscribe to stay tuned, should be dropping in a few weeks

    • @navarone77
      @navarone77  5 місяців тому +1

      Hey there, I've uploaded the code/project used in the video. Hope it helps
      github.com/navarone77/UnityPlayerLogin_Example

  • @xpi8857
    @xpi8857 7 місяців тому +1

    I tried and couldn't get the avatar. Is there any way to get the avatar?

    • @navarone77
      @navarone77  7 місяців тому

      Very interesting question, this might be an upcoming feature unity is implementing, I will look into a way to get this done beforehand though.
      thanks!

  • @hansfritz6026
    @hansfritz6026 9 місяців тому

    i rewatched everything still dont see what i missed is there maybe something set in LoginBtn for events that you didnt show ?

    • @navarone77
      @navarone77  7 місяців тому

      Hey could you provide more details on how and when you get error message ? I'm trying to look into it

  • @NASA-Educational
    @NASA-Educational 5 місяців тому

    so only the unity team can see if someone login to your app? like user's name,email and id?

    • @navarone77
      @navarone77  5 місяців тому

      I'm not entirely sure how they handle the data in UGS, look into their PrivacyPolicy/TOS.
      Likely they only have access to the same public info you do, nothing private.

  • @weiruowei4576
    @weiruowei4576 3 місяці тому +1

    your login is helpful, but I am not sure how it log out here?

    • @navarone77
      @navarone77  3 місяці тому +1

      Hi Thanks for watching! to Sign out you can call
      AuthenticationService.Instance.SignOut
      you can pass a bool in the method to clear credentials / stored session.
      Link to Docs:
      docs.unity.com/ugs/en-us/packages/com.unity.services.authentication/2.6/api/Unity.Services.Authentication.IAuthenticationService#Unity_Services_Authentication_IAuthenticationService_SignOut_System_Boolean_
      You might also need to call
      PlayerAccountService.Instance.SignOut();
      Beforehand
      Hope it helps :)

    • @weiruowei4576
      @weiruowei4576 3 місяці тому

      @@navarone77 thank you very much for your response, but I have problem when using onclick event. It won't give appropriate drop down menu every time ,so my button is not triggered

    • @navarone77
      @navarone77  3 місяці тому

      @@weiruowei4576 wdym by "the appropriate dropdown"
      are you talking about the onclick event?have you dragged in the OnClick event the component/script that is on the gameobject ? make sure its not the one from the Project View

  • @frostypixelsgames9350
    @frostypixelsgames9350 9 місяців тому +1

    how do you log out ? of the account, it alays logs tothe same account on google

    • @navarone77
      @navarone77  9 місяців тому +1

      good question, I will look into this again tomorrow for sure and will get back at you with an answer.
      Did you try the AuthenticationService class Logout method already?
      iirc that should delete any previous tokens, will verify how it is on browser thought to be sure.

    • @frostypixelsgames9350
      @frostypixelsgames9350 9 місяців тому

      yes, i found out the solution it works , but the browser keeps remembering the auth@@navarone77

    • @aize7887
      @aize7887 4 місяці тому

      @@navarone77 I tried AuthenticationService.Instance.SignOut(true); but seem the player haven't acutally signed out
      "PlayerAccountsException: Player is already signed in. Unity.Services.Authentication.PlayerAccounts.PlayerAccountServiceInternal.StartSignInAsync (System.Boolean isSigningUp) (at ./Library/PackageCache/com.unity.services.authentication@3.3.1/Player Accounts/Runtime/PlayerAccountServiceInternal.cs:60)"

    • @aize7887
      @aize7887 4 місяці тому

      @@navarone77 Could you help us fix this, please?

    • @navarone77
      @navarone77  4 місяці тому

      @@aize7887 hey did you check my previous reply ? There should be a logout method on the AuthenticationService

  • @zarplay.official
    @zarplay.official 5 місяців тому +1

    Is it possible to block players through this system?

    • @navarone77
      @navarone77  4 місяці тому

      You can disable an account with Player Management system.

    • @zarplay.official
      @zarplay.official 4 місяці тому

      ​@@navarone77how?

    • @zarplay.official
      @zarplay.official 4 місяці тому

      ​@@navarone77hooow?

    • @zarplay.official
      @zarplay.official 4 місяці тому

      You delete comment?

    • @navarone77
      @navarone77  4 місяці тому

      @@zarplay.official No I don't think so. It still shows fro me. I said you can disable accounts inside the Player Management system

  • @juancarlosiglesiasburgueno5296
    @juancarlosiglesiasburgueno5296 7 місяців тому

    And how to register? Or it is in? Sorry for my atrevement but first is register. Please tell me. Thanks.

    • @navarone77
      @navarone77  5 місяців тому

      The account is already a registered account by using the other providers, you can also sign up with email and password. It takes care of registration for you

  • @NASA-Educational
    @NASA-Educational 5 місяців тому

    how to logout after login?

    • @navarone77
      @navarone77  5 місяців тому

      AuthenticationService.Instance.SignOut
      will sign out, you can pass a bool to clear credentials.
      Docs:
      docs.unity.com/ugs/en-us/packages/com.unity.services.authentication/2.6/api/Unity.Services.Authentication.IAuthenticationService#Unity_Services_Authentication_IAuthenticationService_SignOut_System_Boolean_