Google API returning error accessNotConfigured - google-api

I recieve This a google error when using the url directly along with a newly created project (with no other projects listed) I continously get the below error....
{
"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."
}
}
I know there have seen a few posts on this subject. and I have followed the instructions listed. I even created new project...
turned on fusion table in console (tried with both only fusion api on and nothering else & standard api
generated public key with the referers *
Consent screen filled out
fusion table Download allowed checked
shared with permission for "anyone with link" is selected
url = https://www.googleapis.com/fusiontables/v1/tables/105Otxh5ltQsKBr-ABqYJ8vBuB6E9Ped2MfXj3AZy/templates?&key=AIzaSyCr_wIc0aEHUG6Pl08kHDYLqWRB_PqZsE0
docid = 105Otxh5ltQsKBr-ABqYJ8vBuB6E9Ped2MfXj3AZy
key = AIzaSyCr_wIc0aEHUG6Pl08kHDYLqWRB_PqZsE0
Just what am I missing. I have the google php api client to use a service account.. but if I cant pull up the tables, query or anything via the base api url then i can move forward... untill then Im stuck. Thank in advance anyone!

Related

Google Classroom API says it's disabled, but actually isn't

I have a problem using Google Classroom API for accessing the list of classrooms. I get the following error:
Google_Service_Exception: {
"error": {
"code": 403,
"message": "Google Classroom API (QA) has not been used in project XYZ before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/qa-classroom.sandbox.googleapis.com/overview?project=XYZ then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"errors": [
{
"message": "Google Classroom API (QA) has not been used in project XYZ before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/qa-classroom.sandbox.googleapis.com/overview?project=XYZ then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"domain": "usageLimits",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com"
}
The problem is that it does not detect that the Classroom API is activated, because I'm pretty sure it is. If i go to the developer console and search for it, it shows up and it is activated, and it was activated more than 24h ago.
When I click on the link that the error shows me, it takes me to the developer console but the page is in blank, and if I open the Firefox console, I can see there is an error that says:
ERROR Error: ga Object: {"message":"Permission denied to get service [qa-classroom.sandbox.googleapis.com]\nHelp Token: MYTOKEN","permissionDenied":true,"errorExperience":2}`
I actually tried to delete the project and do it again with a new one, but I get the same result.
I use other APIs as Group Settings, Calendar, Contacts... and all work well, but Classroom doesn't.
Basically this is the code I'm trying to use:
$connection = new Google_Client();
$connection->setClientId($clientId);
$connection->setSubject($delegatedAdmin);
$connection->useApplicationDefaultCredentials();
$connection->setIncludeGrantedScopes(true);
$connection->addScope(Google_Service_Classroom::CLASSROOM_COURSES);
$classroomService = new Google_Service_Classroom($connection);
$params = array(
'pageSize' => 10,
'pageToken' => NULL
);
$response = $classroomService->courses->listCourses($params);
The scopes are correctly configured in Security > API Controls. And I repeat, every other API call from Group Settings, Calendar or Contacts, works just fine.
Does anyone have any idea of what I'm doing wrong?
The problem was that we were using an old version of the google library, and the root link of the API was deprecated.
I had to change
$this->rootUrl = 'https://prod-day0-classroom.sandbox.googleapis.com/';
to
$this->rootUrl = 'https://classroom.googleapis.com/';
Now it's working fine.

Drive v3 API files method gives "invalid parameter" error when used with corpora=domain

I need to access all files of an organisation in TeamDrives via a server-to-server app. All users that have access to the files have emails username#organisation-domain.
I created a service account and see it listed in the Google Console (Oganisation -> Project -> IAM Admin -> IAM) together with the currently logged user (username#organisation-domain) that has the admin role and the full access to the files in TeamDrives.
Via this service account I make request "/drive/v3/files?corpora=domain" which returns:
"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
though there's no "q"-parameter.
If I remove "corpora=domain" part, I get all files that belong the service account.
I tried to add any q-parameter just to try, e.g. "q=name+contains+'text'". Without corpora everything is ok - I get the filtered files (belonging the service account of course). If I add corpora=domain, I get the same error about invalid parameter.
I tried corpus=domain, corpora=DOMAIN etc. from other answers, no result. corpus=domain and corpus=DOMAIN give the same error. corpora=DOMAIN and corpora=default give "Invalid Value" error (without location).
No matter what I try I just keep getting this strange error - invalid value in the q even if there's no q-parameter.
I tried also
corpora: "teamDrive",
includeTeamDriveItems: true,
supportsTeamDrives: true,
teamDriveId: 'XXX',
The service account (via email name#id.iam.gserviceaccount.com) has been added to the members of the TeamDrive ID in the request, but I get:
"domain": "global",
"reason": "teamDriveMembershipRequired",
"message": "The attempted action requires Team Drive membership."
Any ideas what do I do wrong?

Google Rest Api not working

I have been trying to use the google rest api for google webmaster integration into my system.
After going through it's documentation i am able to configure all it's OAuth keys and client id so when i use the Api Explorer i am getting the required reponse there.
There itself i get some url like this :
https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fwww.abcd.in?key={YOUR_API_KEY}
I am providing client secret key in the YOUR_API_KEY but when i hit the url in browser i get this error :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
PS: i didnt't get any api key while generating the OAuth key (if you think i shud have used any kind of API key here ).
Can anyone help ?
You need to go to Google developer console and register your own project. Make sure to enable the webmasters api and create oauth2 credentials.
The Key parameter only works for public data. Webmaster tools data is private user data so you will be using an access token and not a public api key
https://www.googleapis.com/webmasters/v3/sites/https%3A%2F%2Fwww.abcd.in?access_token={YOUR_ACCESS_TOKEN}
There is a bug in the explorer where it shows key instead of access token it has been reported to Google.
Once you have done that i recommend you find a client library in your chosen language to help you with the authentication part.
"message": "Login Required"
Means that you haven't authenticated your user properly. You should check the documentation for oauth2 or find a client library to help you code it.

"400: Unsupported service specified, INVALID_ARGUMENT" from Google Cloud Logging API

I am trying to manually write a log entry using Google Cloud Logging API.
Before doing this via code, I am first trying to do it using the Google APIs Explorer. Here is a screen shot of the request I've built using this tool:
In projectsId I have the Google Project Id that I've copied from the
Google Developer Console.
Likewise for metadata.projectId.
In metadata.userId I have the Client Id of the same Service account that I'm using to authenticate (OAuth2) against the Google Logging API.
Google Logging API is enabled for the project.
The Service account belong to the project and has the "Can edit" permission.
I'm 99% sure that I've setup OAuth2 correctly for the request.
When I execute this request, I get the following response:
{
"error":
{
"code": 400,
"message": "Unsupported service specified",
"status": "INVALID_ARGUMENT"
}
}
Why? and how can I fix this?
The error message was actually telling me exactly which argument was invalid - The serviceName I supplied was bogus ("test").
As soon as I set the serviceName to be "compute.googleapis.com", the problem went away and I received a 200 status code indicating success.

Cannot add notification endpoints for Google APIs project

I have an application where I use OAuth2 to grab some info from a users spreadsheet in Google Drive. I have just completed the OAuth2 procedure, which I thought was the challenging part since there are no OAuth2 libraries for xquery, but now I am running into another problem.
I send a GET request to the Google Drive SDK, which I have turned ON in the Google API Console, and get the following output:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
I have found this question which seems to be the cause of my error :Google API returning Access Not Configured but I am unable to complete the solution to my problem which is to " Visit code.google.com/apis/console. First, make sure the service you want is enabled under "Services". Then go to "API Access" and specify your calling domains or IP addresses." When I try to add my domain to the notification endpoints, it doesn't do it.
In addition, I see that it says "Allows webhook notifications to be sent to external domains that are owned by the user. Google verifies that the user does in fact own each of the listed domains via Webmaster Tools" in the box where you add said endpoints. Since I am on an Amazon EC2 instance I am not sure that I will be able to do that. I really hope the fact that I am on an Amazon server is not stopping me from making my app.
Any help would be appreciated, thank you all.
You should enable Drive SDK and Drive API in the API console.

Resources