标签: google-admin-sdk

Google Calendar API查看/编辑房间/资源?

Google Calendar API是否有某种方法可以查看通过API检索会议时预订了哪些会议室?

还有办法通过Calendar API向会议添加会议室资源吗?

google-calendar-api google-admin-sdk

7
推荐指数
3
解决办法
8144
查看次数

Google管理员目录用户错误

使用Google API .NET Client v1.3.0-beta.

我创建了一个控制台应用程序,用于从服务帐户的示例代码中测试Google Admin Directory的基础知识.这应该给我一个域中所有电子邮件地址的计数.

using System;
using System.Collections.Generic;        
using DotNetOpenAuth.OAuth2;        
using Google.Apis.Admin.directory_v1;
using Google.Apis.Admin.directory_v1.Data;
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Services;
using Google.Apis.Util;

namespace ConsoleApplication1
{
    class Program
    {
        private const string SERVICE_ACCOUNT_EMAIL = "012345678901@developer.gserviceaccount.com";
        private const string SERVICE_ACCOUNT_ID = "012345678901.apps.googleusercontent.com";
        private const string SERVICE_ACCOUNT_PKCS12_FILE_PATH = @"C:\ConsoleApplication1\randomlyassigned-privatekey.p12";    

        static void Main(string[] args)
        {
            X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret", X509KeyStorageFlags.Exportable);
            var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate)
            {
                ServiceAccountId = SERVICE_ACCOUNT_EMAIL,
                Scope = AdminService.Scopes.AdminDirectoryUser.GetStringValue()
            }; …
Run Code Online (Sandbox Code Playgroud)

c# directory google-api google-apps google-admin-sdk

7
推荐指数
1
解决办法
1893
查看次数

Google_Service_Directory - (403)未授权访问此资源/ api

我只是使用PHP api的实际版本的示例,并使用examples文件夹的"service-account.php"文件.

原始版本用于显示"Books API",并且使用我的个人凭据配置它运行良好,但在我的xcase中,我需要通过directory.groups.get服务访问以获取Google群组邮件列表的成员帐户列表,所以我改变了原来的代码:

<?php

session_start();
include_once "templates/base.php";

/************************************************
  Make an API request authenticated with a service
  account.
 ************************************************/
require_once realpath(dirname(__FILE__) . '/../autoload.php');

/************************************************
 ************************************************/

// MY ACCOUNT DATA HERE
$client_id = 'xxx';
$service_account_name = 'xxx'; //Email Address 
$key_file_location = 'xxx.p12'; //key.p12
$groupKey = 'xxx';

echo pageHeader("My Service Account Access");
if ($client_id == '<YOUR_CLIENT_ID>'
    || !strlen($service_account_name)
    || !strlen($key_file_location)) {
  echo missingServiceAccountDetailsWarning();
}

$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
//$service = new Google_Service_Books($client); //ORIGINAL
$service = new Google_Service_Directory($client);

/************************************************
 ************************************************/
if (isset($_SESSION['service_token'])) …
Run Code Online (Sandbox Code Playgroud)

php api google-api-php-client google-admin-sdk

7
推荐指数
1
解决办法
1万
查看次数

Google Directory API:使用服务帐户检索用户信息时出现 403

这可能与使用 showDeleted=true 的 Google Directory API 返回 403 for user_list 有关,但不幸的是,我无法发表评论,而且我没有提供答案。

我从学校的 G Suite获得了一个经过许可的服务帐号

https://www.googleapis.com/auth/admin.directory.user.readonly
Run Code Online (Sandbox Code Playgroud)

G Suite 管理员表示他已将域范围的权限委派给该帐户,并且我能够创建服务帐户 JWT 并检索访问令牌以使用 HTTP/REST 流调用 API。但是,当我调用用户获取端点以请求有关帐户的信息时 -

https://www.googleapis.com/admin/directory/v1/users/redacted%40redacted.com?projection=full
Run Code Online (Sandbox Code Playgroud)

我收到以下信息:

The remote server returned an error: (403) Forbidden.
{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "forbidden",
        "message": "Not Authorized to access this resource/api"
      }
    ],
    "code": 403,
    "message": "Not Authorized to access this resource/api"
  }
}
Run Code Online (Sandbox Code Playgroud)

我无权访问他们的 G Suite 管理面板,所以我无法浏览自己,但管理员已确认我们的客户可以访问他可以找到的任何地方的 admin.directory.user.readonly 权限,我们正在具有域范围访问权限的角色,如上所述。我愿意接受有关管理员可能缺少指定权限的地方的建议,或者我的方法中可能缺少的任何内容(尽管 JWT 构建/签名和访问令牌检索似乎按预期工作)。如果我可以提供任何其他有用的信息,请告诉我,我会更新。

更新:该帐户的权限似乎是正确的 …

google-admin-sdk

7
推荐指数
1
解决办法
2415
查看次数

与C#中的Google Admin SDK集成

我目前正在尝试通过C#与Google Admin SDK集成,以便我们可以通过自己的系统管理用户。但是,在运行项目时出现错误:未经授权的客户端。

我已经通过超级管理员帐户完成的操作:

这是我正在使用的代码。

ServiceAccountCredential credential = new ServiceAccountCredential(
                new ServiceAccountCredential.Initializer(_googleServiceSettings.Client_Email)
                {
                    ProjectId = _googleServiceSettings.Project_Id,
                    User = "superadmin@google.com",
                    Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser }
                }.FromPrivateKey(_googleServiceSettings.Private_Key));

            var service = new DirectoryService(new BaseClientService.Initializer
            {
                HttpClientInitializer = credential,
                ApplicationName = "Test API"
            });

            var request = service.Users.Get("user@google.com");
            var result = await request.ExecuteAsync();
Run Code Online (Sandbox Code Playgroud)

我得到的全部错误是

执行请求时发生未处理的异常。Google.Apis.Auth.OAuth2.Responses.TokenResponseException:错误:“ unauthorized_client”,说明:“客户端未经授权使用此方法检索访问令牌,或者客户端未获得所请求的任何范围的授权。”,Uri:“”

c# google-api google-api-dotnet-client google-admin-sdk gsuite

7
推荐指数
2
解决办法
588
查看次数

Google API/获取目录联系人

我需要从 google 商务目录列表中获取联系人/电话列表。

我已经尝试过 Google 通讯录 api,它适用于“我的联系人”下的所有联系人,但不允许显示“目录”联系人。

我有什么用途/如何访问那些联系人(公司联系人)?

google-api google-contacts-api google-api-python-client google-admin-sdk

6
推荐指数
1
解决办法
3091
查看次数

使用Google API Client Library for Java更改批量HTTP请求的READ TIMEOUT

我正在批量请求将成员添加到组.为此,我使用OAuth2.0并获取类类型Credential的对象.执行时,batch.execute()抛出一个

java.net.SocketTimeoutException : Read timed out
Run Code Online (Sandbox Code Playgroud)

要更改超时限制,这是我找到的解决方案: GoogleApps客户端仅提供SocketTimeOutException

但我无法更改我正在创建的Credential对象的超时.

Credential credential = new AuthorizationCodeInstalledApp(
                flow, new LocalServerReceiver()).authorize("user");
Run Code Online (Sandbox Code Playgroud)

注意:凭据实现HttpRequestInitializer.

提前致谢!

java google-api-java-client google-admin-sdk google-directory-api

6
推荐指数
1
解决办法
1307
查看次数

需要帮助格式化Google API的日期时区

我从bigquery记录中检索了一个日期时间(使用google.cloud.bigquery库),需要根据此api方法的'startTime'参数将其发送到rfc 3339格式的google admin sdk reports API .API期望datetime看起来像这样:

2010-10-28T10:26:35.000Z

通常可以通过创建没有tzinfo的python datetime并调用isoformat来实现这一点:

>>> now = datetime.utcnow()
>>> now = now.isoformat("T") + "Z"
>>> now
'2017-06-01T13:05:32.586760Z'
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是来自BigQuery的时间戳包含一个tzinfo对象,这导致isoformat返回Google API无法处理的文本.

>>> timestamp_from_bigquery
'datetime.datetime(2017, 5, 31, 16, 13, 26, 252000, tzinfo=<UTC>)'
>>> timestamp_from_bigquery.isoformat("T") + "Z"
'2017-05-31T16:13:26.252000+00:00Z'
Run Code Online (Sandbox Code Playgroud)

具体来说,Google的API不接受+00:00作为startTime.如果我从字符串手动删除+00:00 API调用工作,但我不知道如何在没有丑陋的字符串黑客的情况下在python中执行此操作.有没有一些干净的方法从datetime对象中删除它?

我也尝试了这个,但结果相同:

>>> timestamp_from_bigquery.replace(tzinfo=None)
'2017-05-31T16:13:26.252000+00:00Z'
Run Code Online (Sandbox Code Playgroud)

python google-api google-bigquery google-admin-sdk

6
推荐指数
1
解决办法
992
查看次数

通过 Google API 获取 Google Org 中的所有日历

目标:我正在尝试获取我的 Gsuite 组织中的所有日历。

问题:我知道我可以使用日历列表CalendarList.list,但前提是用户或服务帐户的列表中包含所有日历,即使如此,它也不总是准确的,因为日历并不总是添加到服务帐户的日历列表中中用户可能会从他们的列表中删除日历。

问题:有没有办法获取我的 Google 组织中的每个日历?假设我的域名是@someorg.com。我想要每个用户的日历以及通过 api 创建的日历。我认为这可以通过 GSuite Admin SDK 实现,但我找不到任何可以让我做到这一点的东西。它只处理Resources.calendars与 a 不同的Calendar

任何帮助表示赞赏!谢谢!

calendar google-calendar-api google-api google-admin-sdk

6
推荐指数
1
解决办法
2584
查看次数

如何自动化 Firebase FCM 推送通知发送集成测试

我有一个在 Java Cloud Function 中运行的进程,并使用Firebase admin sdk向 Firebase 的 FCM 发送通知。

我目前正在使用模拟 FCM 类的单元测试对此进行测试。

我想添加系统级测试来验证集成是否正常工作。理想情况下,我想执行云函数并断言 FCM(或模拟服务)收到包含预期内容的请求。

我目前已经尝试过。

  • 模拟 FCM:由于 FCM 客户端使用GOOGLE_APPLICATION_CREDENTIALS进行初始化,因此似乎无法提供凭据以便客户端将请求发送到模拟服务。
  • 注册 Android 客户端并断言通知接收:设置非常麻烦,在某些情况下可能需要几分钟时间,导致不稳定。
  • 使用 Firebase Local Emulator Suite:它似乎还不支持 FCM。

这样做的最好方法是什么?

integration-testing system-testing firebase google-admin-sdk firebase-cloud-messaging

6
推荐指数
0
解决办法
406
查看次数