question

programacion avatar image
programacion asked

Google Play Sign In Doc obsolete and Apple Login/link docs inexistent

Grettings,

The documentation related to the Google Play Services Sign in HERE is really outdated since Google changed the Developer console and the Play services and Authenetication structure.

I tried the Sign in example project, the playfab version there is pretty outdated too. Anyway I was unable to get the stuff working, and guessing the outdated instructions of the doc is quite hard. I was able to activate google play and init the login sequence, which prompts the login popup and the permission asking, but after accepting I just get an "Authentication failed" error, which I think is probably some incorrect or missing step in the Google configuration.

Also the Apple Login / linking docs are pretty weak since doesn't say anything about the code side, or how to obtain the parameters of the LinkAppleRequest or the LoginWithAppleRequest..

I searched everywhere about the documentation above but cannot find an updated tutorial or docs.

I used Playfab in the past and was able to get a solid and stable framework and I think you did a great work, but I'm a bit surprised about the outdated Authentication docs.

Thank you

unity3dAccount ManagementAuthentication
10 |1200

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

programacion avatar image
programacion answered

Hi, I finally managed to get the Google Sign in - Playfab - Unity working. Using

GoogleSignIn.DefaultInstance.SignIn().ContinueWith(
              OnGoogleAuthenticationFinished);

And some extra steps in the backend config.

Now About the Apple sign in, I managed to get the Unity Sign in with Apple working to the point I can retrieve de JWT, etc but I keep getting a "NotAuthorized" response with using the "LinkWithApple" method.

Update:

- I can retrieve the JWT of Apple but it comes in a Byte[] array. Would be safe to just convert it to string like Convert.ToBase64String(appleIdCredential.IdentityToken) and passing it into the LinkAppleRequest parameter?

Update 2:

- Even with the JWT converted into string keeps saying "NotAuthorized".

Update 3:

So I get an "appleIdCredential.IdentityToken" from Apple, which says "A JSON Web Token (JWT) that securely communicates information about the user to your app.". Then convert it to string and pass it into the LinkAppleRequest, but still ge this error:

JWT: 'ZXlKcmFXUWlPaUk0TmtRNE9FdG1JaXdpWVd4bklqb2lVbE15TlRZaWZRLmV5SnBjM01pT2lKb2RIUndjem92TDJGd2NHeGxhV1F1WVhCd2JHVXVZMjl0SWl3aVlYVmtJam9pWTI5dExrSnNhWE56UjJGdFpYTXVTblZsWjI4ek1pSXNJbVY0Y0NJNk1UWXhOalU1TVRreE5pd2lhV0Y23wSWpveE5qRTJOVEExTlRFMkxDSnpkV0lpT2lJd01EQXpOamN1Tm1VM1pHUXhOR0poTkdSak5EZGpPVGt3Tm1aaU1E32VNR1F4TW1RNFpUWXVNVEF3TVNJc0ltTmZhR0Z6YUNJNkltRkNabVV5Y1ZaWmRFdFNiRUppV0U1UU9ITlpUbWNpTENKbGJXRnBiQ0k2SW1Sb2VUUjRhM2wyZDJaQWNISnBkbUYwWlhKbGJHRjVMbUZ3Y0d4bGFXUXVZM2l0SWl3aVpXMWhhV3hmZG1WeWFXWnBaV1FpT2lKMGNuVmxJaXdpYVhOZmNISnBkbUYwWlY5bGJXRnBiQ0k2SW5SeWRXVWlMQ0poZFhSb1gzUnBiV1VpT2pFMk1UWTFNRFUxTVRZc0ltNXZibU5sWDNOMWNIQnZjblJsWkNJNmRISjFaWDAuTFFGSko0TWRWOHRWaHlSV2l4bzZTOFVmUklNSFVkNWk2bmNYaUpBeTBNSXFfclkwVDdFeGhvWHRYSVRyTERqZnZ3bUxBNG9KZWYwNGJTLVdCbm9XTndsbmhDSllUM250dkRlMkctQUVxYW9pZmNibEZWZGk3R0pHY0gwT01Ga3ZuaWx6X0Y0NGN4YWdNQUVlMUZKZkFDVEJRYzFQbDhwcklFR0xuVDdCZkwyTllnZ0d5ekRad2hnd3FRQXF6dWE1SGpJOGMxVUtnLTVjQXJxY1R5UFJWcUlKNjk0eUdhQ1dPeGZuWE1MTlExMnBOb1Y5NTU5RUEwVzRUX1FzQWxmN2NDaklMckE1Zk5RR2Z6TTA5eFpGM2RxT0d6bHlYWUpTNmlXV2RMYVM3WG1QMF8zSi12ckY0M1VTZDhSeVhGdmJvOGRxMU8zcjNxdlFhWVA3SjNmZnBn' must have three segments (JWS) or five segments (JWE).

Thanks.

4 comments
10 |1200

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

Rick Chen avatar image Rick Chen ♦ commented ·

Could you please describe the detail steps of how you set up the Apple signin? Have you followed this document: https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/platform-specific-authentication/apple-open-id and setup Apple on PlayFab?

1 Like 1 ·
programacion avatar image programacion Rick Chen ♦ commented ·

Hi, yes I did follow every step.

I'm using this asset that seems an improved version of the Asset Store one:

https://github.com/lupidan/apple-signin-unity

I followed every step of the guide and also configured de Apple Addon.

I'm successfully login into the apple account and retrieving the JWS, I'm still not sure if the param "IdentityToken" that the method LinkWithApple() needs is just the Byte[] JWS that the apple sign in returns converted to string or if is there any step between.

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ programacion commented ·

You mentioned that you are using Convert.ToBase64String to transform the byte array into string. Could you please try using the Encoding.UTF8.GetString instead to get the string from the appleIdCredential.IdentityToken? That is suggested in the github source you provide.

0 Likes 0 ·
1.png (65.2 KiB)
Show more comments
Rick Chen avatar image
Rick Chen answered

Since the Google Play Developer Console update, there is no Linked apps section in the console anymore. Instead, you could follow this document: Get your Google API client ID to create OAuth client ID first. Then login to https://console.cloud.google.com/apis/credentials and choose your project and choose the Web application type client id. The web client ID, secret and other stuff mentioned in the document can be found in that page. Please refer to this thread: https://community.playfab.com/questions/49230/playfab-google-integration.html. Apologize for the inconvenience. I will report this issue to the doc team.

For the Apple Login / linking document, unfortunately there is no platform specified. The LoginWithApple and LinkApple APIs take an “IdentityToken” as parameters This parameter is the JSON Web token (JWT) returned by Apple after login. Represented as the identityToken field in the authorization credential payload. You could search for how to obtain the Apple JWT on the platform you are using. You could also check this document: Authenticating Users with Sign in with Apple for detail about sign in with Apple flow.

10 |1200

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

programacion avatar image
programacion answered

Thanks for the answer.

I think I managed to setup everything up, sadly I'm still unable to Authenticate.

I will write up every step, if anyone see something missing I'll apreciate the help:

On Google Dashboard:

1. Setup the app on Google Console, setup everything for internal testing, including testers (This is working, and got everything running in device)

2. On Play Game Services > Configuration

a. Create a Game Server Credential on Google Services (The only one that allows to select a Web app auth)

b. Create an oAuth client ID as Web Application.

1- On "Authorised Javascript origins", put https://[private].playfabapi.com

2- On "Authorised Redirect URIs", put https://oauth.playfab.com/oauth2/google

3- Copy the ClientID & Client Secret for the playfab addon section & Unity sdk config.

c. On >Oauth Consent screen, add the same testers.

3. Back to Play Games Services "Configuration", copy the content of "Get Resources".

On Playfab

- Add Google Addon

- Paste all the info above. Get the license Key from the Developer Console > Monetization

On Unity:

- Download the SDK

- Window > Play Game Services > Setup

- Paste Resources & ClientID.

- Done.

Code:

To activate:

 public void ActivateGoogleServices()
        {
            PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .AddOauthScope("profile")
            .RequestServerAuthCode(false)
            .Build();
            PlayGamesPlatform.InitializeInstance(config);
            PlayGamesPlatform.DebugLogEnabled = true;
            // Activate the Google Play Games platform
            PlayGamesPlatform.Activate();
            Debug.Log("Activating Google Play Services");
        }

To Authenticate and Link with Playfab:

 public void OnSignInButtonClicked()
        {
            Debug.Log("Init Social Local User Auth.");
            Social.localUser.Authenticate((success) =>
            {
                if (success)
                {
                    Debug.Log("Auth was a success!");
                    try
                    {
                        Debug.Log("Linking to playfab with google.");
                        string serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();
                        print("Auth Code: " + serverAuthCode);
                        var loginRequest = new LinkGoogleAccountRequest()
                        {
                            ForceLink = false,
                            ServerAuthCode = serverAuthCode
                        };
                        PlayFabClientAPI.LinkGoogleAccount(loginRequest, (result) =>
                        {
                        }, OnGoogleError);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("Error Getting Id Token: " + e.Message);
                    }
                }
                else
                    Debug.Log("Authentication Failed: Make sure you add your account to testers.");
            });
        }

> Upload as Internal Test

> Download by the tester

> Authentication triggers the services signing in popup and permissions, but then stops and triggers the log Debug.Log("Authentication Failed: Make sure you add your account to testers.");

1 comment
10 |1200

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

Rick Chen avatar image Rick Chen ♦ commented ·

Thank you for the detailed description of the flow. The error seems to occur before calling the PlayFabClientAPI.LinkGoogleAccount function. I will try to reproduce the issue. Your patience is appreciated. Meanwhile, you could try google signin unity package, according to my test, it successfully returned the AuthCode. Please note that this package does not contains PlayFab’s API, you could add it by yourself.

0 Likes 0 ·
Dawid Burek avatar image
Dawid Burek answered

I was adding Google Signin recently, so I feel your pain. In my case I had to replace authentication method:

From:

Social.localUser.Authenticate(OnLogin);

To:

PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, OnLogin);
10 |1200

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

anudeep avatar image
anudeep answered

IS there any set up for this ?

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.