[Google Play Games Services] need access token for Authenticate with a backend server

First thank for nice gpg plugin.
We need an access token for Authenticate with a backend server (https://developers.google.com/identity/sign-in/web/backend-auth) on both IOS and Android. So, please add get access token function to gpg.

P/S I found mistake on intergrate document:
at: .Create( config, function( game_services ) {
http://docs.sdkbox.com/en/plugins/googleplay/v3-js/

but in js code:
this.Create = function (create_result, platform_configuration) {
line 1807 http://docs.sdkbox.com/en/api/gpg/js/sdkboxgpg.js.html

(callback function before config parameter)

==from documents===
//Initialization
var config = new gpg.PlatformConfiguration();
config.SetClientID(‘777734739048-cdkbeieil19d6pfkavddrri5o19gk4ni.apps.googleusercontent.com’);

new gpg.GameServices.Builder()
.SetOnAuthActionStarted( function( result ) {
// Auth started callback
})
.SetOnAuthActionFinished( function( result ) {
// Auth finished callback
})
.SetLogging( gpg.LogLevel.INFO ) // Set Logging level
.EnableSnapshots() // Enable Snapshot (Saved Game) functionailty
.Create( config, function( game_services ) {
// 8
} );

GPG will manage token for you

check out our sample project

We’ll correct the documentation ASAP, the config is no longer needed.

Thank for your reply.
But I need get access token for authenticate with my backend server.
My game have ‘Login with Google’ and I need get access token and send to my server.

Thanks.

We’ll look into the access token for gpg, in the meantime, dose the token from sdkboxplay works for you?

I will try sdkboxplay but I think it works. I need gpg because I want ‘Login with Google’ on both IOS and Android. (sdkboxplay only work on Android, I think).

Thanks.

Hello, @nite.

Q1: Running sdkbox-sample-gpg - is it possible to connect with it to GP, if I’ve compiled it on my computer, so used mine debug.keystore, so new apk will have different SHA-1 signing-certificate fingerprint than yours, described for com.sdkbox.gpg in OAuth 2.0 client ID ?

Q2: I’ve tried to mix old sdkbox-sample-gpg and newer one, and get confused: both compiles ok. When running:
New sample can’t connect to GP. Then I change package_name (in AndroidManifest.xml) and string name="google_app_id"your_number_into_mine (in res\values\strings.xml) - then it’s crashes down just after the start.
Also I create the new empty project, add there sdkbox import gpg, and merge it with the old sample; it works ok and even successfully connects to GP, but when I change all files in “Classes” into files from newer sdkbox-sample-gpg version - it starts, tries to connect (some times success), and after few seconds crashes down.
Both crashes with log No such file or directory: system_server. Any hint, please?

Upd: When I have two devices, what should I do to create a common game match or at last a room? Both devices see each other, but end the Create / Join command with status ERROR_CANCELED = -6 - when I do on another device Create / Join or Invitations (then I see no invitations).

Upd2: Looks my problem is in RealTimeMultiplayerScene.cpp
void RealTimeMultiplayerScene::CreateRoom(cocos2d::Ref *sender) {

auto roomResponse = _game_services->RealTimeMultiplayer().CreateRealTimeRoomBlocking(config, this);

  • it returns -2 == ERROR_INTERNAL == BaseStatus::ERROR_INTERNAL via roomResponse.status;
    then
    if(gpg::IsSuccess(roomResponse.status)){...block_1...}
    there is no prompt/action if if condition is wrong.

Upd3: the log says:
9525 14814 E DataHolderOperation: There is no linked app associated with this client ID.: com.google.android.gms

proj.android\res\values\strings.xml : <string name="service_id">com.sdkbox.hugo.test.gpg.nearby</string>
also it is hard-coded in NearbyConnectionsScene.cpp : server_id = "com.sdkbox.hugo.test.gpg.nearby";

Also I’ve added there <string name="server_client_id">my_project_id-some_chars.apps.googleusercontent.com</string> - same error.

Where I could find a list of APIs I should enable in Google Play Games Services for realtime multiplayer?

Ok, at last I’ve succeed to create the room and to start the match! :slight_smile:
APIs I should enable: https://stackoverflow.com/questions/33366013/my-app-has-no-client-id
My 1-st mistake: now and 6 months ago I was working with not published project - I could connect but not create the room.
My 2-nd mistake: I had to use/update OAuth2 Client ID not only in proj.android\res\values\strings.xml and https://console.developers.google.com/apis/credentials?project= but also at play.google.com/apps/publish/?dev_acc=#LinkedAppsPlace

My next question: two devices exchange messages, but then on one of them my App loose the focus - I get no error/prompt message, but after restore my messages sent status became “fail” - is it ok?

1 Like

Hello, is it now that access token for gpg can get it?
“StateManager :: GetGameServices () -> FetchServerAuthCode” is to get the token?
But in Android there is no such method, compiled incorrect report.