protected function generateCallback($url = [])
    {
        if (empty($url)) {
            $url = $this->authChoice->createClientUrl($this->client);
        } else {
            $url = Url::to($url);
        }
        if (strpos($url, '?') === false) {
            $url .= '?';
        } else {
            $url .= '&';
        }

        $callbackName = 'googleSignInCallback' . md5($this->id);
        $js = <<<JS
function $callbackName(authResult) {
    var urlParams = [];

    if (authResult['code']) {
        urlParams.push('code=' + encodeURIComponent(authResult['code']));
    } else if (authResult['error']) {
        if (authResult['error'] == 'immediate_failed') {
            return;
        }
        urlParams.push('error=' + encodeURIComponent(authResult['error']));
        urlParams.push('error_description=' + encodeURIComponent(authResult['error_description']));
    } else {
        for (var propName in authResult) {
            var propValue = authResult[propName];
            if (typeof propValue != 'object') {
                urlParams.push(encodeURIComponent(propName) + '=' + encodeURIComponent(propValue));
            }
        }
    }

    window.location = '$url' + urlParams.join('&');
}
JS;
        $this->view->registerJs($js, View::POS_END, __CLASS__ . '#' . $this->id);

        return $callbackName;
    }
protected function generateCallback($url = [])
    {
        if (empty($url)) {
            $url = $this->authChoice->createClientUrl($this->client);
        } else {
            $url = Url::to($url);
        }
        if (strpos($url, '?') === false) {
            $url .= '?';
        } else {
            $url .= '&';
        }

        $callbackName = 'googleSignInCallback' . md5($this->id);
        $js = <<<JS
function $callbackName(authResult) {
    var urlParams = [];

    if (authResult['code']) {
        urlParams.push('code=' + encodeURIComponent(authResult['code']));
    } else if (authResult['error']) {
        if (authResult['error'] == 'immediate_failed') {
            return;
        }
        urlParams.push('error=' + encodeURIComponent(authResult['error']));
        urlParams.push('error_description=' + encodeURIComponent(authResult['error_description']));
    } else {
        for (var propName in authResult) {
            var propValue = authResult[propName];
            if (typeof propValue != 'object') {
                urlParams.push(encodeURIComponent(propName) + '=' + encodeURIComponent(propValue));
            }
        }
    }

    window.location = '$url' + urlParams.join('&');
}
JS;
        $this->view->registerJs($js, View::POS_END, __CLASS__ . '#' . $this->id);

        return $callbackName;
    }
protected function generateCallback ( $ url = [ ] ) { if ( empty ( $ url ) ) { $ url = $ this -> authChoice -> createClientUrl ( $ this -> client ) ; } else { $ url = Url :: to ( $ url ) ; } if ( strpos ( $ url , '?' ) === false ) { $ url .= '?' ; } else { $ url .= '&' ; } $ callbackName = 'googleSignInCallback' . md5 ( $ this -> id ) ; $ js =  <<<JS
function $callbackName(authResult) {
    var urlParams = [];

    if (authResult['code']) {
        urlParams.push('code=' + encodeURIComponent(authResult['code']));
    } else if (authResult['error']) {
        if (authResult['error'] == 'immediate_failed') {
            return;
        }
        urlParams.push('error=' + encodeURIComponent(authResult['error']));
        urlParams.push('error_description=' + encodeURIComponent(authResult['error_description']));
    } else {
        for (var propName in authResult) {
            var propValue = authResult[propName];
            if (typeof propValue != 'object') {
                urlParams.push(encodeURIComponent(propName) + '=' + encodeURIComponent(propValue));
            }
        }
    }

    window.location = '$url' + urlParams.join('&');
}
JS ; $ this -> view -> registerJs ( $ js , View :: POS_END , __CLASS__ . '#' . $ this -> id ) ; return $ callbackName ; }
Generates JavaScript callback function, which will be used to handle auth response.
@param array $url auth callback URL.
@return string JavaScript function name.
Generates JavaScript callback function which will be used to handle auth response .