我正在批量请求将成员添加到组.为此,我使用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
我从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) 我的maven项目使用Directory API Client Library for Java,我需要将它作为依赖项包含在内.但是在Directory API Client Library for Java页面中,当我选择maven作为我的构建环境时,在Add Library to Your Project标题下,它总是显示,
"将以下内容添加到pom.xml文件中:
该库正在上传到中央Maven存储库.请几个小时后再回来看看."
过去几周.
由于我在另一个项目中使用了谷歌驱动器依赖,如下所示,
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev60-1.13.2-beta</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我试着这样做,包括,
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-directory</artifactId>
<version>v1-rev28-1.17.0-rc</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但它没有奏效.
而对于重新编码,我的pom也有以下存储库,
<repository>
<id>google-api-services</id>
<url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
</repository>
Run Code Online (Sandbox Code Playgroud)
使用Directory API Client Library for Java的正确maven依赖是什么.
由于自上周以来我一直禁用Google登录身份验证,因此我试图让oAuth 2.0使用服务帐户.我们希望为我们的内部Web应用程序上的用户提供在办公室外设置的机会.
我下载了最新的用于PHP的Google API客户端库.在Google Developer Console中,我为我的应用程序创建了一个新项目并创建了一个Service account凭据.我还启用了API服务:Admin SDK在Developer Console中.

我已授予帐户用户ID访问权限的范围(我认为):

当我使用service-account.php示例并更改详细信息时,我收到带有访问令牌的JSON,但是当我执行CURL请求(与之前相同)以从用户获取电子邮件设置时,"You are not authorized to access this API."会发生错误.
我的代码:
<?php
include_once "templates/base.php";
require_once realpath(dirname(__FILE__) . '/../src/Google/autoload.php');
$client_id = '124331845-DELETEDPART-hbh89pbgl20citf6ko.apps.googleusercontent.com'; //Client ID
$service_account_name = '124331845-DELETEDPART-89pbgl20citf6ko@developer.gserviceaccount.com'; //Email Address
$key_file_location = 'globaltext-4ce09b20cb73.p12'; //key.p12
$client = new Google_Client();
if (isset($_SESSION['service_token'])) {
$client->setAccessToken($_SESSION['service_token']);
}
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array('https://apps-apis.google.com/a/feeds/emailsettings/2.0/'),
$key
);
$client->setAssertionCredentials($cred);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$aOutput = json_decode($client->getAccessToken());
$strEmailAdresSplit …Run Code Online (Sandbox Code Playgroud) php google-api google-oauth google-api-php-client google-admin-sdk
使用Admin SDK的Directory API更新用户信息时收到错误:
400 BAD_REQUEST
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Input: Bad request for ",
"reason" : "invalid"
} ],
"message" : "Invalid Input: Bad request for "
}
Run Code Online (Sandbox Code Playgroud)
尝试为用户更新组织详细信息,如名称,标题和部门
我的示例代码: `
Get users = directoryService.users().get(userEmail);
User user = users.execute();
try{
List<UserOrganization> userOrg = new ArrayList<UserOrganization>();
userOrg = user.getOrganizations();
if(userOrg != null){
UserOrganization f_userOrg = new UserOrganization();
f_userOrg = userOrg.get(0);
if(f_userOrg != null){
f_userOrg.setTitle("SAP Asso");
f_userOrg.setName("xyz company name");
f_userOrg.setDepartment("xyz dept name"); …Run Code Online (Sandbox Code Playgroud) java google-app-engine google-admin-sdk google-directory-api
我在 java web 应用程序中使用以下代码来尝试获取组的所有用户:
GoogleCredential credential = GoogleCredential.fromStream(Util.class.getResourceAsStream("[credential_file].json")).createScoped(SCOPES);
Directory directory = new Directory.Builder(httpTransport, JSON_FACTORY, credential).build();
Directory.Members dirMem = directory.members();
Members members = dirMem.list("[group_email]").execute();
Run Code Online (Sandbox Code Playgroud)
这会导致最后一行 ( dirMem.list...)出现异常 403(未授权访问此资源/API )。
从文档(https://developers.google.com/admin-sdk/directory/v1/guides/delegation)和其他帖子中,我看到解决方案是使用setServiceAccountUser(). 但是,这意味着我必须使用 p12 文件而不是 json 文件(Google 建议在创建密钥时使用 json 文件)。
有什么办法可以在仍然使用 json 文件的同时解决这个问题(它还涉及更少的代码)。
谢谢。
google-api google-api-java-client google-oauth google-admin-sdk
我正在尝试在Angular 4应用中检索当前登录的Firebase用户的UID。但是,如果我将'firebase.auth()。currentUser'登录到控制台,则会得到'null'。因此,“ firebase.auth()。currentUser.uid”给出了“无法读取属性'uid'为null”的错误。
根据这篇文章https://firebase.google.com/docs/auth/web/manage-users,这意味着我当前尚未登录。尽管如此,我可以,因为我可以从数据库中读取数据(规则不允许未经身份验证的用户),并且登录方法未给出任何错误。
我还可以看到具有uid 1的用户已在firebase控制台中登录(... / u / 1 / project / my-project / authentication / users)
我的数据库规则:
{
"rules": {
"users": {
"$uid": {
".write": "$uid === auth.uid",
".read": "$uid === auth.uid"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意:我没有使用任何Firebase登录方法。我正在使用我的php后端来验证用户并为firebase生成自定义令牌,具体方法如下:https : //firebase.google.com/docs/auth/admin/create-custom-tokens。
Angular 4登录代码:
constructor(private afAuth: AngularFireAuth) {
this.login();
}
login() {
console.log('We are logging in on Firebase :)');
firebase.auth().signInWithCustomToken(localStorage.getItem('firebase_token')).catch(function (error) {
console.log(error.message);
console.log('You are not logged in!');
});
this.user = firebase.auth().currentUser;
console.log(firebase.auth().currentUser);
console.log(firebase.auth().currentUser.uid);
}
Run Code Online (Sandbox Code Playgroud)
控制台输出:
chat.service.ts:59 …Run Code Online (Sandbox Code Playgroud) authentication firebase google-admin-sdk firebase-authentication angular
我对 Cloud Firestore 还很陌生(我们不是所有人吗?),我已经使用 Node.js 中的管理 SDK 向我的数据库添加了一些数据。它显示在控制台上,但在文档下显示“此文档不存在,它不会出现在查询或快照中”。我不确定这是为什么?这是一个屏幕截图:
database nosql node.js google-admin-sdk google-cloud-firestore
使用googleapis与火力地堡云功能,能在这个摹套房域中所有用户的列表。
如何实例化 Admin SDK Directory 服务对象。我没有看到 NodeJS 示例,也不清楚如何使用googleapis.
此代码从 Firebase Cloud Functions 运行,并且似乎可以通过身份验证。现在,如何//TODO在以下代码中设置服务对象:
// Firebase Admin SDK
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)
// Google APIs
const googleapis = require('googleapis')
const drive = googleapis.drive('v3')
const gsuiteAdmin = googleapis.admin('directory_v1')
// Service Account Key - JSON
let privatekey = require("./privatekey.json")
let jwtClient = new googleapis.auth.JWT(
privatekey.client_email,
null,
privatekey.private_key,
['https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/admin.directory.user'])
// Firebase Cloud Functions - REST
exports.authorize = …Run Code Online (Sandbox Code Playgroud) node.js jwt service-accounts google-admin-sdk google-cloud-functions
我有一个使用Amazon Route 53管理的域.它包含Amazon Simple Email Service的TXT/MX记录,用于通过AWS Lambda处理传入的电子邮件到某个电子邮件地址.我还需要将域名注册到Google管理员,即GSuite,以便我可以通过Google控制台管理我的商家电子邮件.我该如何实现这一目标?我尝试设置Google管理员,输入了Google Mail的MX记录,但导致AWS SES服务失败.
google-admin-sdk ×10
google-api ×3
java ×3
google-oauth ×2
node.js ×2
amazon-ses ×1
angular ×1
database ×1
firebase ×1
gsuite ×1
jwt ×1
maven ×1
nosql ×1
php ×1
python ×1