google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Error when attempting to connect Adsense on WP.com (Business plan) #1926

Closed ernee closed 4 years ago

ernee commented 4 years ago

Bug Description

A user in the forums reported getting the following error in Site Kit when trying to connect Adsense on WP.com (Business plan) :

“Error: The response is not a valid JSON response.”

console : “{“code”:”rest_forbidden”,”message”:”Sorry, you are not allowed to do that.”,”data”:{“status”:401}}”

As well as the following 403 error on the request:

403 error

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

Additional Context


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

QA Brief

Changelog entry

jamesozzie commented 4 years ago

Another possibly impacted user. Site Health info provided ( Response number 66): https://wordpress.org/support/topic/error-the-response-is-not-a-valid-json-response-4/#post-13286234

S-Waleed commented 4 years ago

I'm getting the same error.

ernee commented 4 years ago

Update that we're working with the team at WP.com to address this issue. We'll update accordingly.

ernee commented 4 years ago

Another report in the forums: https://wordpress.org/support/topic/ad-sense-configuration-on-google-site-kit/

JoshuaGoode commented 4 years ago

Thanks for the report. @adamsilverstein reached out regarding Analytics specifically and we were able to get Analytics connections resolved.

To review, Site Kit responds with a 403 payload when additional permissions are required for Analytics -- prompting the user to grant Site Kit permissions to create a new property.

Something like:

{"code":"missing_required_scopes","message":"You\u2019ll need to grant Site Kit permission to create a new Analytics property on your behalf.","data":{"status":403,"scopes":["https:\/\/www.googleapis.com\/auth\/analytics.edit"]}}

Unfortunately, as soon as our side saw the 403 response, we delivered our custom 403 page instead of what Site Kit was trying to send to the users.

We've now made adjustments to resolve this. After multiple tests, I can confirm this appears to be resolved.


As this mentioned AdSense instead of Analytics, I ran a few more additional tests and could not reproduce the AdSense issue now that we've made this adjustment.

Feel free to ping me if users are still having issues with AdSense.

ernee commented 4 years ago

@JoshuaGoode thanks so much for looking into this! We've gotten confirmation from users that they can now connect to Adsense. I will close this issue as resolved.

jimgarrigan commented 6 months ago

Hi, I recently encountered the same problem, and I independently determined the problem is being caused by a custom 403 page.

I am searching for a simple solution that is better than disabling the custom 403 error page. I am using NGINX.

NGINX/WordPress is not within my area of expertise thus the reason for this message.

Thank you.

At my previous job [July 2019 - July 2023], I interacted with Windows servers and created PowerShell scripts to automate tasks. I had written more than 50,000 lines of code. I envision, create, and implement solutions. I created PowerPoint presentations to illustrate work products. https://www.youtube.com/playlist?list=PLgkRipPFmxPPvjxYbTR-iDrGWWwJMJg0y I appropriately altered details.

Jim https://www.garrigan.nyc

adamdunnage commented 6 months ago

@jimgarrigan Thanks for leaving a comment here. As your issue is with WordPress.com and this isn't a Site Kit specific issue, I would recommend reaching out to the WordPress.com support team who should be able to help you further with this.

jimgarrigan commented 6 months ago

Hi Adam, It appears to me the problem is partially caused by a custom 403 page configured within NGINX.

For example, I changed: error_page 403 /403-error.html; to # error_page 403 /403-error.html;

If someone has a better solution and/or suggestion I am receptive.

Thank you