How can I get my Google Groups via API? I am NOT admin - google-apps-script

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()

Related

Google Drive API v3: how to set canCopy capabilities on a file

I want to limit the capabilities of a file in personal Google Drive. When I use the API explorer Google Drive v3 API with the following request:
POST https://www.googleapis.com/drive/v3/files?key={YOUR_API_KEY}
{
"capabilities": {
"canCopy": false
},
"name": "testfile"
}
I get the following response:
403
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fieldNotWritable",
"message": "The resource body includes fields which are not directly writable."
}
],
"code": 403,
"message": "The resource body includes fields which are not directly writable."
}
}
Which is the same response that I get when trying to update a file with:
PATCH https://www.googleapis.com/drive/v3/files/FileIdHere?key={YOUR_API_KEY}
{
"capabilities": {
"canCopy": false
}
}
It seems that there are no methods to accomplish this or has anyone a workaround?
If you check file resource you will notice that some fields are writeable while others are not.
The message you are seeing is because the field you are trying to set is not writeable this means you can not change it from the API

Google Reports API

I need to create simple Java application for Reports API (https://developers.google.com/admin-sdk/reports/v1/guides/manage-audit-drive)
But I can't understand is this Reports available only for business users or also for all users?
How can I develop applications for G suite without buy it?
For example, I'm sending this request via Postman - https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/drive
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."
}
}
Best regards,
Aleksandr.

Unable to share a file in Team Drive with anyone with link and for people outside organization

I would like to use Google Drive API to share a file with anyone that has the link to view the file.
However, i failed with error 403, even if I used admin account
"code": 403,
"message": "The user does not have sufficient permissions for this file."
I tried using the API Explorer but still failed.
Followings are my parameters, please help
fileID:"xxxxxxx"
Request Body
{
"role": "reader",
"type": "anyone"
}
And the response
Response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientFilePermissions",
"message": "The user does not have sufficient permissions for this file."
}
],
"code": 403,
"message": "The user does not have sufficient permissions for this file."
}
}
Please check and help.
Thanks

Access Not Configured 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!

Get file information through api

I'm not able to get information about a file.
Here it is my situation:
I'm logged in google drive
Through google picker I get the file ID
Then I type the url https://www.googleapis.com/drive/v1/files/[file ID]
But I get the following error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
How can I sort it out?
You can't retrieve the file metadata by typing the url in your browser.
Instead you need to send an authorized request with a valid OAuth 2.0 token.
For more information:
https://developers.google.com/drive/about_auth