question

Mubarak Almehairbi avatar image
Mubarak Almehairbi asked

Get Server Auth Code for LoginWithGoogleAccountRequest in C#

Hi, I want to allow users to login using google in my Desktop game. However, I do not know how to get the Server Auth code that LoginWithGoogleAccountRequest needs:

My code looks something like this:

using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;


public class LoginManager: MonoBehaviour
{
    string GetServerAuthCode() {

    }

    void LoginUsingGoogle() {
        var request = new LoginWithGoogleAccountRequest { CreateAccount = true, ServerAuthCode = GetServerAuthCode()};
        PlayFabClientAPI.LoginWithGoogleAccount(request, OnLoginUsingThirdPartySuccess, OnLoginUsingThirdPartyFailure);
    }
}

I want to write the appropriate code under GetServerAuthCode.

Account Management
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

·
JayZuo avatar image
JayZuo answered

You can try with Using OAuth 2.0 for Web Server Applications.

The redirect URIs can be set to "**https://oauth.playfab.com/oauth2/google**".

The access scopes can be set to profile.

Then follow the steps to get the authorization code.

Once you've got the authorization code, you can use it as ServerAuthCode in LoginWithGoogleAccount API.

Here is a tutorial for Android. It should be similar for desktop apps.

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.