Hey everyone! I'm making a game for telegram using Unity.
Telegram provides a user id that i want to use to sign in to unity services to use cloud save and save user data in between sessions and devices.
Unity AI is proposing to use SignInWithCustomIdAsync, but i can't find any info on such method.
So i had to create a Cloud Code js script that does sign in with custom id and returns id and session tokens - as described in unity docs (https://services.docs.unity.com/docs/client-auth/#custom-id-authentication).
The whole flow works like this:
- sign in anonymously - for cloud code to work;
- call cloud code - to get new session data for user with custom id;
2.1. cloud code calls token exchange api to get stateless token;
2.2. cloud code signs in user with custom id;
2.3. cloud code returns idToken and sessionToken; - sign out - to be able to authenticate with id and session token;
- sign in via id and session token that i get from cloud code.
- we have successfully logged in with custom id.
One of the issues i have with this is that unity web api docs suggest to keep the stateless token (result of step 2.1) locally and refresh when expired, but i can't really do that as it is serverless function.
Another issue is that it seems kinda cumbersome and inefficient with sign in anonymous and the sign out to sign in again...
So does it even make sense to use unity cloud for signing in with custom id?
Or would it be better to move this cloud code script to other BE service?
Maybe there are some suggestions for how would it be better to log in with custom id?
Client APIs are endpoints that allow you to access Unity Services as a Unity project user. These endpoints are called inside the project after