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.
Related
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()
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>"
}
We have a hybrid Exchange deployment. Trying to create a subscription to get updates, creates, deletes on Calendar and Contacts.
In Graph Explorer I'm logged in as an Office 365 user that has full access to the On-Premise mailbox I'm trying to access (user#domain.com). I'm entering:
POST | v1.0 | https://graph.microsoft.com/v1.0/subscriptions
Request Body:
{
"changeType": "updated",
"notificationUrl": "https://our.URL/WebHooks/Graph/GraphMessagesHook.php",
"resource": "users/user#domain.com/contacts",
"expirationDateTime": "2018-10-23T04:00:00Z",
"clientState": "secret"
}
Response is:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: NotFound; Reason: Not Found]",
"innerError": {
"request-id": "981c0892-e6d8-490b-838d-880d8268037f",
"date": "2018-10-20T20:32:07"
}
}
}
As a test, I created another user in Office 365 and did the same request body:
{
"changeType": "updated",
"notificationUrl": "https://our.URL/WebHooks/Graph/GraphMessagesHook.php",
"resource": "users/userOn365#domain.com/contacts",
"expirationDateTime": "2018-10-23T04:00:00Z",
"clientState": "secret"
}
This time instead of a 404 NotFound, I got a 403:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: Forbidden; Reason: Forbidden]",
"innerError": {
"request-id": "1f378cf0-b1ec-4b87-ba03-8dee120b748b",
"date": "2018-10-21T20:42:46"
}
}
}
What am I missing?
The Microsoft Graph API for on premise mailboxes is only a subset of the cloud functionality.
Don’t think they implemented subscriptions for on-premise mailboxes. That would be pretty resource intensive on both sides.
To my knowledge they just proxy the request to your local Exchange (which is configured to accept the Azure tokens). For rest calls that is easy, for subscriptions the routing would be difficult.
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
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!