question

duartedd avatar image
duartedd asked

google account single sign on with windows unity

so 3 platforms:

ios android and windows

looking for 3 different SSO techniques

facebook ( no problem)

google account - with windows platform it doesnt appear to work - googleplaygames only works with android and ios -

for instance from the playfab blog

PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() .AddOauthScope("profile") .Build(); PlayGamesPlatform.InitializeInstance(config); PlayGamesPlatform.Activate();

doesnt compile and has issues because windows platform is selected and not android

apple id - not sure yet havent gotten that far yet.

anyone know if there is an alternative for windows platform for google account and probably apple id


not sure if anyone from playfab has run into this before and if there is something else for this ? - like i know openid is a thing but not sure with google

10 |1200

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

duartedd avatar image
duartedd answered

doesnt look like thatll work for windows, that method is only for ios and android

here is what i found: it looks like i have to make my application a redirector while the login call is being made...this way the browser can send the information back to the client and then i can send the rest of the information to playfab to login and link and whatever else...alternatively i can setup a server somewhere else to host this redirector but then i will need to configure the unity client to interface with that server which may make things more difficult.

If i can get this redirector going i can theoretically make any oauth 2.0 compliant provider work with playfab for any platform and i wont have to do any custom login.

reference

https://developers.google.com/identity/protocols/OAuth2InstalledApp

examples of existing unity assets:

https://assetstore.unity.com/packages/tools/network/web-api-kit-oauth-token-interceptor-extension-40572

^this uses a server hosted by that team and redirects the data which i am not a fan of

https://assetstore.unity.com/packages/tools/network/api-buddy-61427

^this may be the way to go for ease if you dont want to set it up yourself

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.

Citrus Yan avatar image Citrus Yan commented ·

Great, did you manage to do that?

0 Likes 0 ·
Citrus Yan avatar image
Citrus Yan answered

For Google account login on Windows Platfrom, maybe you can consider setting up PlayFab authentication using Google and HTML5, which does not require Google Play Games SDK, please navigate to the link for more details.

As per Sign in with Apple, you can refer to this tutorial to get started: Setup Sign In with Apple for PlayFab.

10 |1200

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

duartedd avatar image
duartedd answered

my game isnt based off of html5 - im doing it in untiy - would make more sense to use openid connect but im not sure if playfab has the same functionality as it does with openid connect - and Ill have to transpose the documentation to openid connect based - think i found this

PlayFabClientAPI.LoginWithOpenIdConnect - for some reason the links

https://docs.microsoft.com/en-ca/rest/api/playfab/admin/authentication/createopenidconnection?view=playfab-rest

and the

https://docs.microsoft.com/en-us/rest/api/playfab/client/authentication/LoginWithOpenIdConnect?view=playfab-rest

didnt actually state the api calls - and that apple link doesnt actually state the api call for apple either - in which i cant find the api call for the apple one - or am i sued loginwithopenidconnect since it seems like that is what apple uses anyways ( supposedly they didnt exactly cause they didnt design to spec but they fixed that since)?????

basically just want some confirmation that the openid connect is the way i should go and i wont lose any functionality - like in the players you get the facebook thing shown if its faceboook is it gonna say openid connect - google (or whatever name i name it?)

10 |1200

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

duartedd avatar image
duartedd answered

further i just noticed i cant find how to unlink open id connect logins????

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.

duartedd avatar image duartedd commented ·

o hahah nevermind i found it - playfab typod the method I think :::

UninkOpenIdConnectRequest

guess thats considered a bug - should be an easy fix for playfab though

0 Likes 0 ·
duartedd avatar image
duartedd answered

also shouldnt new LinkOpenIdConnectRequest {} take some parameters...?

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.

duartedd avatar image duartedd commented ·

o got them

/// <summary> /// A name that identifies which configured OpenID Connect provider relationship to use. Maximum 100 characters. /// </summary> public string ConnectionId; /// <summary> /// If another user is already linked to a specific OpenId Connect user, unlink the other user and re-link. /// </summary> public bool? ForceLink; /// <summary> /// The JSON Web token (JWT) returned by the identity provider after login. Represented as the id_token field in the /// identity provider's response. Used to validate the request and find the user ID (OpenID Connect subject) to link with. /// </summary> public string IdToken;

0 Likes 0 ·
duartedd avatar image
duartedd answered

getting this when i try to create one for google

Unable to retrieve connection discovery data: "IDX20108: The address specified 'Vaults/.well-known/openid-configuration' is not valid as per HTTPS scheme. Please specify an https address for security reasons. If you want to test with http address, set the RequireHttps property on IDocumentRetriever to false. Parameter name: address".

10 |1200

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

duartedd avatar image
duartedd answered

also i tried some urls in the 'issuer' but i get the url + .well-known/openid-configuration - so i figured id google and found https://accounts.google.com/ so i tried that and it worked ...so i guess the issuer looks for the this openidconfig well known thing (guess its part of the openid spec) and playfab checks for it before creating it - hope im doing this right.

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.

duartedd avatar image duartedd commented ·

not exactly sure how to get this info for the request:

IdToken True
  • string
The JSON Web token (JWT) returned by the identity provider after login. Represented as the id_token field in the identity provider's response.
0 Likes 0 ·
duartedd avatar image
duartedd answered

aight so i think i got everything ready to go for a test google one - just need to know what and where this JWT is and what i need to do with it - since the doc says i need that token for LoginWithOpenIdConnectRequest but how am i supposed to get the response from the provider ?

unless i need to do this first:
CreateOpenIdConnection but i set this up in the game manager already so i dont need to set this through my program...so just lost here

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.

duartedd avatar image duartedd commented ·

yup so it shows invalid params - so just need to know what to do with JWT - i have a json file that i downloaded from google - but not sure what playfab is looking for - it doesnt really make sense that i would send that file over since that data already exists in game manager and just makes things more insecure since my secret key is in there - id rather not have data miners grab that secret key,

0 Likes 0 ·
duartedd avatar image
duartedd answered
    public static void StartOpenIDLogin(string connectionid)
    {
        PF_Authentication.connectionid = connectionid;

  
            OpenIDInitCallback(); 
    }


    private static void OpenIDInitCallback()
    { 
        var request = new LoginWithOpenIdConnectRequest { ConnectionId = connectionid, TitleId = PlayFabSettings.TitleId };
        PlayFabClientAPI.LoginWithOpenIdConnect(request, OpenIDSuccessLoginCallback, OnLoginError);
    }
    private static void OpenIDSuccessLoginCallback(PlayFab.ClientModels.LoginResult result)
    {
        var oiAction = PlayFabClientAPI.IsClientLoggedIn() ? PlayFabAPIMethods.LinkOpenId : PlayFabAPIMethods.LoginWithOpenID;
          
        // PlayFab Facebook Login
        if (oiAction == PlayFabAPIMethods.LinkOpenId)
            LinkOpenIDToPlayFab();
        else
            PlayFabLoginWithOpenID( true);
    } 


    public static void LinkOpenIDToPlayFab( )
    {
        MenuHandleRequests.RequestLoadingPrompt(PlayFabAPIMethods.LinkOpenId);
        var request = new LinkOpenIdConnectRequest { ConnectionId = connectionid, ForceLink = false };
        PlayFabClientAPI.LinkOpenIdConnect(request, OnLinkOpenIDSuccess, error =>
        {
            if (!error.ErrorMessage.Contains("already linked")) // ew, gotta get better error codes
            {
                PF_Bridge.RaiseCallbackError(error.ErrorMessage, PlayFabAPIMethods.LinkOpenId, MessageDisplayStyle.error);
                return;
            }


            PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.LinkOpenId, MessageDisplayStyle.none);
            Action<bool> afterConfirm = (bool response) =>
            {
                if (!response)
                    return;


                MenuHandleRequests.RequestLoadingPrompt(PlayFabAPIMethods.LinkOpenId);
                request.ForceLink = true;
                PlayFabClientAPI.LinkOpenIdConnect(request, OnLinkOpenIDSuccess, PF_Bridge.PlayFabErrorCallback);
            };


            MenuHandleRequests.RequestConfirmationPrompt("Caution!", "Your current facebook account is already linked to another Vaults player account. Do you want to force-bind your Facebook account to this player?", afterConfirm);
        });
    }


    private static void OnLinkOpenIDSuccess(EmptyResult result)
    {
        Debug.Log("openid Linked Account!");
        PlayerPrefs.SetInt("LinkedOpenID", 1); 
        PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.LinkOpenId, MessageDisplayStyle.none);
    }


    public static void UnlinkOpenIDAccount()
    {
        var request = new UninkOpenIdConnectRequest();
        PlayFabClientAPI.UnlinkOpenIdConnect(request, result =>
        {
            Debug.Log("Unlinked Account.");
            PlayerPrefs.SetInt("LinkedFacebook", 0);
            PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.UnlinkOpenID, MessageDisplayStyle.none);
            FB.LogOut();
        }, PF_Bridge.PlayFabErrorCallback);
    }


10 |1200

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

duartedd avatar image
duartedd answered

okay so i think i know whats up - i thought playfabs api would also call the login request and such - i am getting that is not the case and that is the issue. so basically dont think it lll work

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.