question

oleksandrtunik avatar image
oleksandrtunik asked

Anonymous login creates account no metter CreateAccount is TRUE or FALSE

I faced such a case

In playfab space I have 2 environments test and production

And when I try to login with LoginWithAndroidDeviceIDAsync, LoginWithIOSDeviceIDAsyncsuch as user that doesn`t have account in one titlebut has in another titlein the same space, no metter if I create request with CreateAccount TRUE or FALSE, this call creates account of this user at new title for there

Can you explain why does it work like this?
And how to login as user with this methods and don`t create account in title if it`s doesn`t contain it?

Code of authentification

public class PlayFabClientAuth
    {
        public string _TitleID;
        public string _Devkey;
        private LoginWithCustomIDRequest WithCustomIDRequest;
        private LoginWithAndroidDeviceIDRequest WithAndroidDeviceIDRequest;
        private LoginWithIOSDeviceIDRequest WithIOSDeviceIDRequest;
        private GetAccountInfoRequest GetAccountInfoRequest;
        public PlayFabResult<LoginResult> result;
        public PlayFabResult<GetAccountInfoResult> account;


        public PlayFabClientAuth(string titleId, string Devkey, string ClientId)
        {
            _TitleID = titleId;
            _Devkey = Devkey;
            WithCustomIDRequest = new LoginWithCustomIDRequest() { TitleId = titleId, CreateAccount = false, CustomId = ClientId };
            WithAndroidDeviceIDRequest = new LoginWithAndroidDeviceIDRequest() { TitleId = titleId, CreateAccount = false, AndroidDeviceId = ClientId };
            WithIOSDeviceIDRequest = new LoginWithIOSDeviceIDRequest() { TitleId = titleId, CreateAccount = false, DeviceId = ClientId };
        }


        public async Task TryToLogIn()
        {
            Semaphor.PlayFabSemaphore.WaitOne();


            PlayFabSettings.staticSettings.TitleId = _TitleID;
            PlayFabSettings.staticSettings.DeveloperSecretKey = _Devkey;


            result = await PlayFabClientAPI.LoginWithCustomIDAsync(WithCustomIDRequest);
            if (result.Error != null)
            {
                Console.Error.WriteLine("Custom " + result.Error.HttpStatus);
                result = await PlayFabClientAPI.LoginWithAndroidDeviceIDAsync(WithAndroidDeviceIDRequest);
                if (result.Error != null)
                {
                    Console.Error.WriteLine("Android " + result.Error.HttpStatus);
                    result = await PlayFabClientAPI.LoginWithIOSDeviceIDAsync(WithIOSDeviceIDRequest);
                    if (result.Error != null)
                    {
                        Console.Error.WriteLine("IOS " + result.Error.HttpStatus);
                    }
                }
            }
            if (result.Error == null)
            {
                GetAccountInfoRequest = new GetAccountInfoRequest() { PlayFabId = result.Result.PlayFabId };
                account = await PlayFabClientAPI.GetAccountInfoAsync(GetAccountInfoRequest);
            }


            Semaphor.PlayFabSemaphore.Release();
        }
    }
Authentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

>>Can you explain why does it work like this?

Referring to the LoginWithAndroidDeviceID API reference: “CreateAccount: Automatically create a PlayFab account if one is not currently linked to this ID. ” The PlayFab account stated above refers to the Master Player Account, which spans across all titles in your studio. And, since you’ve already created and linked that PlayFab account to the aforementioned Device Id in another title, therefore, when you were trying to login with DeviceID in the second title, what actually happened is that PlayFab automatically creates a Title Player Account for the player instead of the Master Player Account. As I see it, these APIs are behaving normally.

>>And how to login as user with this methods and don`t create account in title if it`s doesn`t contain it?

In the current context, I think the “account” you are referring to is the Title Player Account, as a matter of fact, PlayFab will automatically create it as long as the DeviceId is still linked to another Master Player Account. If you insist on doing this, you’ll need to first unlink the DeviceId from that Master Player Account, however, if there are no other recoverable login mechanisms attached to that account, it will then becomes orphaned, meaning that it would be hard for you to login to that account again.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.