Hi,
I have tried to analyze url page using pagespeedonline api client library but fails with 403 "Forbidden". The api is enabled in the console and the billing is also enabled but the request always fails with 403 "Forbidden"
Please help
Below is the code:
NetHttpTransport.Builder builder = new NetHttpTransport.Builder();
NetHttpTransport httpTransport = builder.build();
httpTransport.createRequestFactory(new MyInitializer());
PagespeedonlineRequestInitializer requestInitializer = new PagespeedonlineRequestInitializer(
API_KEY);
Pagespeedonline.Builder pagespeedbuilder = new Pagespeedonline.Builder(
httpTransport, new JacksonFactory(), new MyInitializer());
pagespeedbuilder.setPagespeedonlineRequestInitializer(requestInitializer);
Pagespeedonline pageSpeedOnline = pagespeedbuilder.build()
Runpagespeed pageSpeed = pageSpeedOnline.pagespeedapi().runpagespeed("http://www.google.com");
Result res = pageSpeed.execute();
Below is the curl response:
{ "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." } }