我们尝试使用RingCentral SDK连接到RingCentral中的JavaScript令牌身份验证URL。
https://platform.devtest.ringcentral.com/restapi/oauth/token
我们得到Http 400(坏请求)-未经授权的这个授予类型错误。
400 Bad Request
{
"error": "unauthorized_client",
"error_description": "Unauthorized for this grant type",
"errors": [
{
"errorCode": "OAU-251",
"message": "Unauthorized for this grant type"
}
]
}
这是我的代码:
var SDK = require('ringcentral');
var rcsdk = new SDK({
server: SDK.server.sandbox,
appKey: 'appkey',
appSecret: 'appSecret',
redirectUri: ''
});
rcsdk.platform()
.login({
username: 'phone number', // phone number in full format
extension: 101, // leave blank if direct number is used
password: 'password'
})
.then(function(response) {
console.log(response)
})
.catch(function(e) {
console.log(e.message || 'Server cannot authorize user');
});
提前感谢
发布于 2017-12-10 17:52:48
此JS请求使用的是OAuth 2.0密码流授予类型。要将其与RingCentral API一起使用,需要确保应用程序在应用程序的OAuth设置中为此授予类型配置了应用程序。
有关如何做/验证这一点的答案,请参见下面的Stack溢出线程,包括屏幕截图。
https://stackoverflow.com/questions/47679082
复制