WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics Dashboard for WP
[resolved] Could not json decode the token (9 posts)

  1. klode
    Member
    Posted 10 months ago #

    Hi,
    in my website it works fine, as on many other websites with the same version of WordPress.
    But on http://klode.altervista.org I get this error:

    <b>Fatal error</b>:  Uncaught exception 'Google_AuthException' with message 'Could not json decode the token' in /membri2/klode/wp-content/plugins/google-analytics-dashboard-for-wp/src/auth/Google_OAuth2.php:153
    Stack trace:
    #0 /membri2/klode/wp-content/plugins/google-analytics-dashboard-for-wp/src/auth/Google_OAuth2.php(104): Google_OAuth2->setAccessToken('Protection: 1; ...')
    #1 /membri2/klode/wp-content/plugins/google-analytics-dashboard-for-wp/src/Google_Client.php(131): Google_OAuth2->authenticate(Array, '4/ewERQTDvMRcIO...')
    #2 /membri2/klode/wp-content/plugins/google-analytics-dashboard-for-wp/ga_dash.php(339): Google_Client->authenticate('4/ewERQTDvMRcIO...')
    #3 [internal function]: ga_dash_content('', Array)
    #4 /membri2/klode/wp-admin/includes/template.php(925): call_user_func('ga_dash_content', '', Array)
    #5 /membri2/klode/wp-admin/includes/dashboard.php(204): do_meta_boxes('dashboard', 'normal', '')
    #6 /membri2/klode/wp-admin/index.php(129): wp_dashboard()
    #7 {main}
      thrown in <b>/membri2/klode/wp-content/plugins/google-analytics-dashboard-for-wp/src/auth/Google_OAuth2.php</b> on line <b>153</b><br />

    Infact I get this JSON string (it's not a real JSON string!):

    Protection: 1; mode=block
    Server: GSE
    Alternate-Protocol: 443:quic
    Transfer-Encoding: chunked
    
    {
      "access_token" : [redacted],
      "token_type" : "Bearer",
      "expires_in" : 3600,
      "refresh_token" : [redacted]
    }

    How can I resolve this issue?

    http://wordpress.org/plugins/google-analytics-dashboard-for-wp/

  2. Alin Marcu
    Member
    Plugin Author

    Posted 10 months ago #

    @klode: OMG, edit your post and remove the access_token and refresh_token immediately!

    @Ipstenu or @esmi please moderate that value, if the user won't do it.

  3. esmi
    Forum Moderator
    Posted 10 months ago #

    Access & refresh token values removed.

    @klode: Never ever post tokens or any other sensitive information on a public forum.

  4. Alin Marcu
    Member
    Plugin Author

    Posted 10 months ago #

    Google API has an issue when websites are behind a proxy, like those hosted by altervista.

    can you try to go to src/io/Google_CurlIO.php

    and add

    $respData = preg_replace('/^HTTP.+HTTP/is', 'HTTP', $respData);

    before

    // Parse out the raw response into usable bits
        list($responseHeaders, $responseBody) =
              self::parseHttpResponse($respData, $respHeaderSize);

    Keep in mind that a plugin update will overwrite the fix.

  5. klode
    Member
    Posted 10 months ago #

    Thanks... I'll try right now!

  6. klode
    Member
    Posted 9 months ago #

    After apply the editings on Google_curlIO.php, I get this new error:

    Invalid json in service response:
    Help on WordPress Forum
    Support on Deconf Forum

    what do you think? Does some other problem regarding Altervista?

  7. klode
    Member
    Posted 9 months ago #

    In the configuration page, I get this:

    Lock selected access level to this profile:

    with a red arrow, and the text:

    your profile list needs an update: Click here

    And when I click on link, I get the dashboard, with the error above.

  8. Alin Marcu
    Member
    Plugin Author

    Posted 9 months ago #

    That red warning is generated by the fact that the plugin is unable to get to the step of retrieving the profiles list. It can't get there because there is a JSON error (your error log should contain more details)

    I think altervista's platform is not compatible with the GAPI client library. You should also have a look here: http://wordpress.org/support/topic/dashboard-error-8?replies=27

    Being a new error I thought we could make it work, but I guess we can't.

  9. klode
    Member
    Posted 9 months ago #

    Hi,
    I've found a possible solution on the file Google_CurlIO.php.

    The problem is that $respHeaderSize is not correct in some case. So the line 122 of this file can be replace from:

    $respHeaderSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

    to:

    $respHeaderSize = strpos($respData, "{");

    I wish this solution can be good! :)

Reply

You must log in to post.

About this Plugin

About this Topic