Tag: google admin sdk

NodeJS示例 – Firebase云function – 实例化Admin SDK目录服务对象

目标 在Firebase云端函数中使用googleapis获取我的G Suite域中所有用户的列表。 题 如何实例化一个Admin SDK目录服务对象 。 我没有看到一个NodeJS的例子,我不清楚如何设置和使用googleapis的请求。 上下文 此代码从Firebase云端函数运行,似乎可以进行身份​​validation。 现在,我如何在//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, […]

如何使用JWT使用NodeJS客户端库访问Google Directory(Admin SDK)?

我正在尝试创build一个服务器应用程序,将用户添加/删除到我的域组。 请注意,它不会与用户有任何交互,它是服务器到服务器的应用程序。 我在Google API Console中注册我的应用程序,下载密钥并通过发布将其转换为.pem openssl pkcs12 -in my_google_key.p12 -out my_google_key.pem -nocerts -nodes 然后我去了域pipe理,安全 – >高级设置 – >authentication – >pipe理OAuth客户端访问。 在那里,我在授权API客户端添加了一条logging。 我使用了我从Console中的服务帐户获得的客户端ID,并使用范围: https://www.googleapis.com/auth/admin.directory.group. 我安装了用于nodejs的googleapis npm install googleapis 这是我的代码: var googleapis = require('googleapis'); var SERVICE_ACCOUNT_EMAIL = 'My Service Account E-mail Address'; var SERVICE_ACCOUNT_KEY_FILE = 'my_google_key.pem'; // The .pem file is at the root of my application […]