标签: google-admin-sdk

Google:拒绝为localhost生成目标域的登录提示权限

我正在尝试创建Google登录并收到错误消息:

权限被拒绝为目标域生成登录提示

之前纪念这个副本,这是一样的问题,在问在网站错误谷歌标志:权限被拒绝生成目标域登录提示,因为在这种情况下,提问者是在本地主机上,而我得到的这个错误服务器.

具体来说,我在Authorized Javascript Origins中包含了服务器的url,如下图所示: Javascript起源

当我收到错误时,请求显示发送了相同的URL,如下图所示: 无效的请求页面

我还应该在限制页面中添加其他内容吗?有没有办法弄清楚这里发生了什么?开发人员控制台上是否有日志可以告诉我发生了什么?

google-admin-sdk google-signin

40
推荐指数
4
解决办法
3万
查看次数

如何在用户启用两步验证时收到更新通知?

我创建了一个频道来在用户更新时发送我的应用通知,如下所示:

data = {
    'id': channel_id,
    'type': 'web_hook',
    'address': domain_address,
    'kind': 'api#channel',
}
channel = directory.users().watch(body=data, domain=my_domain, event='update').execute()
Run Code Online (Sandbox Code Playgroud)

当我在Admin SDK GUI中更新用户时,这会成功发送通知.但是,当用户采取导致其信息更新的操作(例如登录,更改其密码或启用两步验证)时,我不会收到任何通知.

我的最终目标是在用户启用两步验证时收到通知,即isEnrolledIn2Sv属性从何时更改FalseTrue.有没有办法做到这一点?

谢谢!

编辑:我使用的解决方法是创建一个webhook(我使用AWS Lambda)来查询已知isEnrolledIn2Sv属性设置为的所有用户False,并查看是否有任何已更改为True.有用!但不理想,所以如果有其他人知道更清洁的方法,那就更愿意听到.

python google-admin-sdk

24
推荐指数
1
解决办法
375
查看次数

Google Apps管理Java API中的批处理操作

我编写了一个Java应用程序,用于在我们的Google Apps for Education域上同步Google网上论坛(功能类似于Google Apps School Directory Sync,但针对我们的某些特定需求进行了定制).

同步有效,但速度很慢,因为它正在单独执行每个任务.我知道有批处理操作的 API接口,但我找不到任何关于如何使用Java API实现它的示例.

我正在使用的代码看起来与此类似(身份验证和其他设置在其他地方处理):

try
{
    Member m = new Member ();
    m.setEmail (member);
    m.setRole ("MEMBER");
    service.members ().insert (group, m).execute ();
}
catch (Exception e)
{
    // ERROR handling
}
Run Code Online (Sandbox Code Playgroud)

我不是一个一个地执行这些操作,而是想要批量处理它们.谁能告诉我怎么样?

java google-apps-for-education google-admin-sdk

15
推荐指数
1
解决办法
478
查看次数

使用Google Admin SDK Directory API时,"域名无法使用apis"

我正在尝试使用Admin SDK Directory API,专门用于检索Users:get端点详细说明的用户信息.

我在oauthing时请求了以下权限

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

但是,当我发出获取特定用户信息的请求时,我得到以下响应:

HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=UTF-8
Date: Fri, 26 Jul 2013 18:25:29 GMT
Expires: Fri, 26 Jul 2013 18:25:29 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "domainCannotUseApis",
    "message": "Domain cannot use apis."
   }
  ],
  "code": 403,
  "message": "Domain cannot use apis."
 }
}
Run Code Online (Sandbox Code Playgroud)

我在API控制台中启用了Admin SDK .

我在Google Apps标准版(免费版)和Google Apps …

google-admin-sdk

14
推荐指数
1
解决办法
9298
查看次数

?Google OAuth?AttributeError:“InstalledAppFlow”对象没有属性“run_console”

我编写了一个 Python 脚本(Google_add.py),用于在 Google Workspace 中创建用户。然而,当它运行时,发生了 AttributeError 。如何解决此错误?

\n

\xe3\x83\xbbGoogle_add.py\xe3\x80\x80(摘录\xef\xbc\x89

\n
PATH = \'/opt/Google/credentials.json\'\nCLIENT_SECRETS = \'/opt/Google/client_secrets.json\'\ncredentials = None\n\n#If there are credentials\nif os.path.exists(PATH):\n    credentials = Credentials.from_authorized_user_file(\n      path = PATH,\n      scopes = SCOPES)\n\n#If there are no (valid) credentials available\nif not credentials or not credentials.valid:\n    if credentials and credentials.expired and credentials.refresh_token:\n      credentials.refresh(Request())\n    else:\n      FLOW = flow.InstalledAppFlow.from_client_secrets_file(\n        client_secrets_file = CLIENT_SECRETS,\n        scopes = SCOPES)\n      credentials = FLOW.run_console()\n    with open(PATH, \'w\') as token:\n      token.write(credentials.to_json())\n
Run Code Online (Sandbox Code Playgroud)\n

\xe3\x83\xbb错误消息

\n
File "Google_add.py", line 186, in <module>\nmain()\nFile "Google_add.py", line 172, …
Run Code Online (Sandbox Code Playgroud)

google-oauth google-api-python-client google-admin-sdk google-workspace

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

如何查找Google Apps帐户的不可变ID?

许多Directory API调用都需要一个客户参数,称为"Google Apps帐户的不可变ID.(字符串)".

如GET https://www.googleapis.com/admin/directory/v1/customer/ 客户 /域

我不知道如何为我的Google Apps帐户查找/生成此内容.我是管理员.

有人能指出我正确的方向吗?

google-admin-sdk

13
推荐指数
2
解决办法
9187
查看次数

使用bash curl和oauth返回谷歌应用用户帐户数据?

我正在寻找一种相当简单的方法来使用curl在google Apps中返回有关一批用户帐户(如createddate或lastlogin)的信息.我对curl和Google Apps api非常缺乏经验.

有没有人知道如何使用curl和Oauth请求用户帐户数据的好文章?

先感谢您!

api curl google-apps oauth-2.0 google-admin-sdk

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

周末有没有改变/破坏Google Directory API的东西?

从今天早上开始,我无法使用原始HTTP协议在User对象上设置orgUnitPath.

PATCH /admin/directory/v1/users/testuser_1440432547467%40example.com

{"orgUnitPath":"/testorgunit_2"}
Run Code Online (Sandbox Code Playgroud)

回报

{
  "error": {
     "errors": [ {
       "domain":"global",
       "reason":"invalid",
       "message":"Invalid Input: Inconsistent Orgunit id and path in request - 8100451664789505, /testorgunit_2"}],
     "code":400,
     "message":"Invalid Input: Inconsistent Orgunit id and path in request - 8100451664789505, /testorgunit_2"
  }
}
Run Code Online (Sandbox Code Playgroud)

OrgUnit ID似乎没有在任何地方记录,但我也注意到,从Directory API返回的数据现在除了orgUnitPath属性之外还包含orgUnitID属性.

{
  ...
  orgUnitId=id:02gyr1s20gshpvd,
  orgUnitPath=/
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以确认是否存在API更改,现在除了orgUnitPath之外还需要提供orgUnitId,或者这是否是刚刚引入的错误?

google-admin-sdk

12
推荐指数
1
解决办法
832
查看次数

为Google Admin SDK创建和设置自定义属性

我一直在阅读有关如何更新用户自定义属性的文档.从如何编写,似乎我将能够做到以下几点:

    email = "a@a.com"
    results = service.users().list(domain="a.com",projection="full",query='email={0}'.format(email)).execute()

    if len(results["users"]) == 1:
        user = results["users"][0]
        user["customSchemas"]["TEST"] = "TEST"
        try:
            userResponse = service.users().update(userKey=email, body=user).execute()
        except HttpError, e:
            print(e)
Run Code Online (Sandbox Code Playgroud)

但是,我抛出了错误:

https://www.googleapis.com/admin/directory/v1/users/test%40test.com?alt=json返回"未授权访问此资源/ api">

我不确定错误是因为我试图错误地更新字段,如果@url中的转义导致问题,或者我没有正确的范围(我正在使用https://www.googleapis.com/auth/admin.directory.user, https://www.googleapis.com/auth/admin.directory.domain, https://www.googleapis.com/auth/admin.directory.userschema).

如何为每个人创建自定义属性并使用python SDK为用户更新?

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

12
推荐指数
2
解决办法
399
查看次数

我无法使用php在我的Google云端硬盘中看到通过api创建的文件和文件夹

我正在尝试使用谷歌驱动器api创建文件夹.我能够在最后得到文件ID.但我无法在谷歌驱动器中的文件夹.看来有些许可问题?

$scopes = array(
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/drive.appdata','https://www.googleapis.com/auth/drive.apps.readonly',
    'https://www.googleapis.com/auth/drive.metadata','https://www.googleapis.com/auth/drive.file',
    'https://www.googleapis.com/auth/drive.readonly','https://www.googleapis.com/auth/drive.photos.readonly'
);
$creds = new Google_Auth_AssertionCredentials(
    $serviceAccountName,
    $scopes,
    file_get_contents($keyFile)
);
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setClientId($clientId);
$client->setAssertionCredentials($creds);
$service = new Google_Service_Drive($client);
$fileMetadata = new Google_Service_Drive_DriveFile(array(
  'name' => 'Invoices',
  'permissions' => array('type'=>'anyone','role'=>'reader','allowFileDiscovery'=>1),

  'mimeType' => 'application/vnd.google-apps.folder'));
$file = $service->files->create($fileMetadata, array());

printf("File ID: %s\n", $file->id);
Run Code Online (Sandbox Code Playgroud)

php google-drive-api google-admin-sdk

11
推荐指数
1
解决办法
1463
查看次数