JavaScript试图使用JavaScript创建一个Glip团队,然后将其实现到我正在创建的应用程序中。我正在按照以下指示进行操作:
https://developers.ringcentral.com/guide/team-messaging/quick-start/node
,我遇到了错误。我不熟悉JavaScript,所以不确定如何处理这些错误。
我正在按照以下说明进行操作:
https://developers.ringcentral.com/guide/team-messaging/quick-start/node
,并且我已经安装了RingCentral JavaScript SDK。我创建了一个文件create-glip-team.js
,并使用我的信息编辑了变量。当我尝试运行代码时,会遇到错误
这是主文件create-glip-team.js
一开始我用我帐户中的正确信息替换了所有变量。
例如 我将RINGCENTRAL_CLIENTID =更改为 RINGCENTRAL_CLIENTID ='XXXXXXXXXXXXXX'我去掉了括号,并留下了单引号
const RC = require('ringcentral')
RINGCENTRAL_CLIENTID = '<ENTER CLIENT ID>'
RINGCENTRAL_CLIENTSECRET = '<ENTER CLIENT SECRET>'
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'
RINGCENTRAL_USERNAME = '<YOUR ACCOUNT PHONE NUMBER>'
RINGCENTRAL_PASSWORD = '<YOUR ACCOUNT PASSWORD>'
RINGCENTRAL_EXTENSION = '<YOUR EXTENSION, PROBABLY "101">'
var rcsdk = new RC({
server: RINGCENTRAL_SERVER,
appKey: RINGCENTRAL_CLIENTID,
appSecret: RINGCENTRAL_CLIENTSECRET
});
var platform = rcsdk.platform();
platform.login({
username: RINGCENTRAL_USERNAME,
password: RINGCENTRAL_PASSWORD,
extension: RINGCENTRAL_EXTENSION
})
.then(function(resp) {
create_glip_team()
});
function create_glip_team(){
var endpoint = "/restapi/v1.0/glip/teams"
var params = {
public: true,
name: "Fun team",
members: [{ email: "member.1@gmail.com"},
{email:"member.2@gmail.com"}],
description: "Let chit chat here"
}
platform.post(endpoint, params)
.then(function(resp){
var json = resp.json()
console.log(JSON.stringify(json))
})
.catch(function(e){
console.log(e)
})
}
编辑此文件以包含我的信息后,我使用
$ node create-glip-team.js
我收到这些错误:
(node:12416) UnhandledPromiseRejectionWarning: Error: Unauthorized for this grant type at Client.<anonymous>
(D:\Users\xx\Documents\Glip\node_modules\ringcentral\src\http\Client.js:62:38)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:12416) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
此代码正常运行后,它将创建一个临时团队,我将能够登录到我创建的新团队。
谢谢
答案 0 :(得分:0)
您的应用似乎不是密码流平台类型。你能仔细检查一下吗?或者给我您的应用名称,以便我为您检查。