pageSpeedOnline.pagespeedapi().runpagespeed(..) function fails with error 403 - google-api

I have tried to analyze url page using pageSpeedOnline.pagespeedapi().runpagespeed(..) api but fails with 403 "Forbidden". The api is enabled in the console and the billing is also enabled but I am blocked further since it always fails with 403. The billing was just enabled since a week back.
Below is the response of the curl request,
curl "https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://code.google.com/speed/page-speed/&key=API_KEY"
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
],
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
}
Please help.

I got it resolved, by creating "Key for browser apps (with referers)" and used that API key in the project.

Related

Google calendar api get error like "domain": "global", "reason": "notFound", "message": "Not Found"

I tried get list of event from calendar example from here.
No matter which property I
use, I always get the 404 "not found" error. Anyone can shed some light on this? Many thanks.
Request.
POST https://www.googleapis.com/calendar/v3/calendars/oneclapp.2021#gmail.com/events?
key=AIzaSyCGRPF0wSSBLndqdUftlbsDH9emHD_S-qg
Accept: "application/json"
Authorization: Bearer ya29.a0ARrdaM9PPHndl040qaXFmoSFGT9yRPWZs_yrTnYLAHQ0GF-UBvGc67S2L1m0O5OFIilq8oVGRuvw29NFwomtmUTBeHoABcIlaVD_p--4NVlBWCcXLBgfDjsF_5tvt4XRShd1itpe_9CULan9x6BV4TOyP__TkQ
Response
Response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "not Found",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
First off events.list is not HTTP Post its a HTTP GET
GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events
Second assuming that you just miss wrote post and you are actually doing a http get.
Not found means just that the currently authenticated user does not have access to the calendar that you are trying to request events for. in this case oneclapp.2021#gmail.com
I recommend using primary to test that you can get the currently authenticated users primary calendar.
GET https://www.googleapis.com/calendar/v3/calendars/primary/events
It looks like you have not configured the OAuth 2.0 Client IDs correctly. We need to configure the OAuth client ID correctly and its type should be 'Web Application'. I was also getting the same error messages, but once I configured the OAuth ID, then it started working.
OAuth id type: Web Application
Permission scopes : https://www.googleapis.com/auth/calendar.readonly, https://www.googleapis.com/auth/calendar, https://www.googleapis.com/auth/calendar.events.readonly, https://www.googleapis.com/auth/calendar.events
Authorized redirect URIs: http://localhost
Here is the screenshot of the Google Calendar API project settings.

Youtube API 3, fetch feed stopped working

I am using the https://www.googleapis.com/auth/youtube.readonly endpoint.
I can successfully Oauth my application, but when I use my keys I get:
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. YouTube Data API has not been used in project 45754353xxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=45754353xxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"extendedHelp": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=45754353xxxx"
}
],
"code": 403
This was working until a few days ago. The link provided above (without the xxxx) fails to load in the google cloud console.
Any ideas?
Thanks.
create a new project, add the api you need to it and add a key for the new project.
i had the same error 403 but now it works fine. hope this help for you

Google G Suite Business Reports API configuration

I'm trying to configure Google Service Account (in developers console) to use it in my application to get Reports API.
I'm getting error - "Access denied. You are not authorized to read activity records". It seems some issue with configuration.
I created new Project and Service Account in Google Developers Console. Added Client ID in Admin Console Settings Manage API client access menu.
Maybe I missed something?
Please, help.
Server response is:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Access denied. You are not authorized to read activity records.",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Access denied. You are not authorized to read activity records."
}
}
You can try to call the .setServiceAccountUser("admins email address") as per described in this SO post if you haven't done yet.

APIs Explorer ipRefererBlocked

How to use Google API Explorer?
https://developers.google.com/apis-explorer/#p/plusDomains/v1/plusDomains.people.get
I would like test Google+ Domains API and even via API Explorer I receive 403 error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
}
This is an app settings issue in the Google Developers Console. On the credentials screen it lists the IPs that are allowed to use the API Key. It's a security precaution to help protect the key if it leaks.
As the picture
You need to edit allowed IPs to either be empty (less secure) or update it to include the actual IP of your server.
As the picture

Google DNS API & Gcloud Console Error

I'm using gcloud console for windows and have enabled the Google DNS API in the developer console. I have authenticated from the gcloud console, but when I try to do anything with the DNS api, I get the following error message:
{
"error": {
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your pro ject.",
"reason": "accessNotConfigured"
}
],
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
} } ERROR: (gcloud.dns.managed-zone.list) ResponseError: status=403, code=Forbidden, reason(s)=accessNotConfigured
message=Access Not Configured. Please use Google Developers Console to
activate the API for your project.
Has anyone else had this problem?
There are a number of things to look at including if you have enabled billing for your project. Follow the link for more information https://cloud.google.com/dns/getting-started

Resources