Where will GPG StartAuthorizationUI second time callback to?

Hi, I finally able to sign in google play service.

i called gameServices.StartAuthorizationUI(), it will go to the function that i set in SetOnAuthActionFinished. It return me
{"AuthCode":"","AuthOperation":1,"AuthStatus":1}

Then i call gameServices.SignOut();. it return me
{"AuthCode":"","AuthOperation":2,"AuthStatus":-3}

When i call gameServices.StartAuthorizationUI() again, but it don’t go back to the the function that i set in SetOnAuthActionFinished this time. Anyone know which function it will go to? the procedure should be same as first time, right?

Secondly, is there a way to get AuthCode or AuthToken when sign in successfully?
because it return me "AuthCode":""

appreciate with anyone can help :pray:

i found out a bug that why 2nd time login cannot return callback

nativeNotify: function (id, str_json) {
        if ( this._callbacks[id] ) {
            try {
                // __log('received id=' + id + ' str=' + str_json);
                this._callbacks[id](JSON.parse(str_json));
            } catch (e) {
                __log('nativeNotify got error ' + e);
            }
        } else {
            // __log('No callback for id: '+id);
            // __log('   params: '+str_json);
        }

        // callbacks that are temporary one shot calls have to be removed.
        if ( id>=1000 ) {
            this._callbacks[id] = null; <---- (this one not sure need to change to undefined or not)
        }
    },

    resetDefaultCallbacks : function() {

        __log('Signed out, clearing default game services callbacks.');

        // clean up previous callbacks
        for (var i = DefaultCallbacks.DEFAULT_CALLBACKS_BEGIN;
             i < DefaultCallbacks.DEFAULT_CALLBACKS_END;
             i += 1) {

            this._callbacks[i] = null; <---- (this one need to change to undefined)
        }
    }

why need to change to undefined, because

addCallbackById: function (id, callback) {
        if (typeof this._callbacks[id] !== 'undefined') { <---- (this checking)
            // already a callback for this value ??
            cc.log('addCallbackById is already defined. id=' + id);
        } else {
            this._callbacks[id] = callback;
        }
    },

since call SignOut need to clear default callbacks, but it set to null so means there are still object in this._callbacks[id], that is why i cannot reassign authActionFinishedCallback again.

this.SetOnAuthActionFinished = function (authActionFinishedCallback) {
                __callbackManager.addCallbackById(
                    DefaultCallbacks.AUTH_ACTION_FINISHED,

                    /**
                     *
                     * @param _authActionFinishedCallback {AuthActionFinishedCallbackParams}
                     */
                    function (_authActionFinishedCallback) {

                        if (_authActionFinishedCallback.AuthOperation === gpg.AuthOperation.SIGN_OUT &&
                            _authActionFinishedCallback.AuthStatus === gpg.AuthStatus.ERROR_NOT_AUTHORIZED) {
                            // clear default callbacks. A new game_services must be created with a new Builder
                            // so previous callbacks are no longer valid.
                            __callbackManager.resetDefaultCallbacks();
                        }

                        // call user defined auth finished callback.
                        authActionFinishedCallback(_authActionFinishedCallback);
                    });
                return this;
            };

I’m not sure is it correct or not, but once i change to undefined, it let me signIn and signOut repeatly :slight_smile:

Thanks for reporting a bug and provide a solution.

1 Like

Hi @yinjimmy,

welcome :slight_smile:
thanks for reply

may i know how to get “AuthCode” ?
because even i login successfully, i still unable to get AuthCode.
I couldn’t solve this. please help.
:frowning:

SDKBox’s GPG plugin use Google Play Games C++ SDK Version 3.0.1 currently, and from version 2.3:

OAuth server auth code is no longer accessible via the Google Play Games Services SDK.

https://developers.google.com/games/services/cpp/releaseNotes