Access Not Configured google drive API - google-drive-api

when i access the google drive uri https://www.googleapis.com/drive/v2/files/1obpi0bmSDILX1cIQcVRNi1lUkm2K5xBFztmRFiM?fields=lastModifyingUserName%2CmodifiedDate%2CownerNames%2CselfLink&key={YOUR_API_KEY}
i have both Drive SDK, Drive API to ON in my services https://code.google.com/apis/console
but still get a:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
where as if i run this through the https://developers.google.com/drive/v2/reference/files/get#try-it it works fine!
how do i return correctly the json?
{
"selfLink": "https://www.googleapis.com/drive/v2/files/1obpi0bmSDILX1cIQcVRNi1lUkm2K5xBFztmRFiM",
"modifiedDate": "2012-12-13T20:41:07.602Z",
"ownerNames": [
"Norman"
],
"lastModifyingUserName": "Norman"
}

i was using an old api key, this now works!

Related

Google Drive API : 403 Request had insufficient authentication scopes

I encountered this Error and i don't known how to resolve this :
2023-02-07 18:11:17.699 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/Draft/DownloadFileInDrive FAILED.
Reason:
com.google.api.client.http.HttpResponseException: 403 Forbidden
GET https://www.googleapis.com/drive/v3/files/1lXeG5nWa9uPyPqSPUQKYrVch7JiQvcjBtOMbohieick?alt=media
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Insufficient Permission",
"domain": "global",
"reason": "insufficientPermissions"
}
],
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
"domain": "googleapis.com",
"metadata": {
"service": "drive.googleapis.com",
"method": "google.apps.drive.v3.DriveFiles.Get"
}
The error is displayed because of this line and does not go further :
FileList result = service.files().list().setPageSize(10).setFields("nextPageToken, files(id, name)").execute();
Could you tell me what's wrong?
Can someone tell me if a forum for Google drive API exists?
Thanks you

How can I get my Google Groups via API? I am NOT admin

I want to get all my groups but I am not an admin
I know how to fetch groups if I am admin. But if not - I don't understand. Also I can see its via website
My steps:
I do auth with Google and with scope
[
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/groups",
]
I fetch groups by GET. Url: "https://admin.googleapis.com/admin/directory/v1/groups?domain=konstructly.com"
I get the next problem:
{
"error": {
"code": 403,
"message": "Not Authorized to access this resource/api",
"errors": [
{
"message": "Not Authorized to access this resource/api",
"domain": "global",
"reason": "forbidden"
}
]
}
}
My question
How can I get my Google Groups via Google API?
I tried:
Auth with scope
[
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/groups",
]
GET "https://admin.googleapis.com/admin/directory/v1/groups?domain=konstructly.com"
Expectation:
List of my groups
Actual result:
{
"error": {
"code": 403,
"message": "Not Authorized to access this resource/api",
"errors": [
{
"message": "Not Authorized to access this resource/api",
"domain": "global",
"reason": "forbidden"
}
]
}
}
Instead of using the Google Workspace Admin SDK, use the Groups Service from Google Apps Script, more specifically GroupsApp.getGroups()

Shared drive not found when trying to run File:list

Tried to test the Drive API v3: Files: list, got following error. I am thr owner of the drive.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Shared drive not found: 1_LWGJfL7OaVHEjMKU1IZ71qIRWh1_0_S",
"locationType": "parameter",
"location": "driveId"
}
],
"code": 404,
"message": "Shared drive not found: 1_LWGJfL7OaVHEjMKU1IZ71qIRWh1_0_S"
}
}

Google Drive API - Files stored in a GSuite Shared Drive (only) get a 404 error

My application has scopes drive.file, drive.readonly and drive.metadata.readonly.
Using https://github.com/googleapis/google-api-php-client v2.2.2
It works fine fetching files when authenticated as a Google Drive user, but only when those files are owned by another user (or the same user).
Files stored on a Shared Drive (G Suite Business feature) and shared with the user result in a 404 error:
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: 1gasqkgWcabla8sksT5FUtZGzlfIwGbc_aI4g2gl9bla.",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: 1gasqkgWcabla8sksT5FUtZGzlfIwGbc_aI4g2gl9bla."
}
I have verified that the file in question is indeed readable by that user via Drive/Docs etc.
I have been into the API Console and checked the "Shared Drives support" under Drive UI integration - this made no difference.
Neither did it help to add the wider 'drive' scope.
After testing I found the same issue.
When I tried to get a file from a Shared Drive with the following HTTP Request
GET /drive/v3/files/<ID-file> HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer <access Token>
I got the same error as you did:
{
"error": {
"code": 404,
"message": "File not found: 1DIM-vS4058e0X5eutNmOqSr3z0rA1Nqh.",
"errors": [
{
"locationType": "parameter",
"domain": "global",
"message": "File not found: 1DIM-vS4058e0X5eutNmOqSr3z0rA1Nqh.",
"reason": "notFound",
"location": "fileId"
}
]
}
}
But upon reading the documentation it's clear that you need to include the supportsAllDrives paramater to the HTTP request.
So now adding supportsAllDrives=true my request is the following:
GET /drive/v3/files/<File ID>?supportsAllDrives=true HTTP/1.1
Host: www.googleapis.com
Content-length: 0
Authorization: Bearer <access Token>>
And then I got to retrieve the file in the response:
{
"mimeType": "image/jpeg",
"kind": "drive#file",
"name": "file.jpg",
"driveId": "<Drive Id>",
"teamDriveId": "<Team Drive ID>",
"id": "<File ID>"
}

Getting 500 backend error on /userlicenses

I am trying to hit /userlicenses api of chromeWebstore api. But i get the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "Backend Error"
}
],
"code": 500,
"message": "Backend Error"
}
}
This is only happening for all the new extensions that are created.
Tried to contact google support but they are no help.
Please can anyone guide as to what can be done in this case?