【问题标题】:RingCentral JavaScript SDK (HTTP 400 - Unauthorized for this grant type)RingCentral JavaScript SDK(HTTP 400 - 未经授权用于此授权类型)
【发布时间】:2018-04-30 09:08:34
【问题描述】:

我们已尝试使用 JavaScript SDK 连接到 RingCentral 中的 RingCentral 令牌认证 URL。

https://platform.devtest.ringcentral.com/restapi/oauth/token

我们收到 Http 400(Bad Request) - Unauthorized for this grant type 错误。

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');
   });

提前致谢

【问题讨论】:

  • 您确定要公开您的应用密钥/秘密吗?我知道这只是测试,但也许用 [appkey] 和 [appSecret] 替换它们是个好主意?与用户名/密码相同。
  • 你的意思是需要数组中的 appkey 吗??
  • 我的意思是你的代码中的那个——全世界都可以在这里看到。
  • @Aaron 抱歉没听懂
  • 您的信息是可见的。我可以看到它的人。如果我能看到,其他人都能看到。如果我愿意,我可以使用您在帖子中提供的密码、ID、用户名和密码来连接到您的端点并访问您的数据。这不是一个很难的概念。看看你的帖子,就在这个上面。它就在那里。此评论上方 6 英寸。您的 appKey 以“DVCy”开头,您的 appsecret 以“DvE2”开头,您的用户名是电话号码,您的密码是人名……全世界都可以看到。 “appSecret”中的“secret”名称应该会提示您。

标签: javascript oauth-2.0 ringcentral


【解决方案1】:

此 JS SDK 请求使用 OAuth 2.0 密码流授权类型。要将其与 RingCentral API 一起使用,您需要确保在您的应用的 OAuth 设置中为您的应用配置此授权类型。

请参阅以下 Stack Overflow 线程,了解我如何执行/验证此问题的答案,包括屏幕截图。

RingCentral Auth Token Failed in Curl Call

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-15
    • 2019-05-11
    • 1970-01-01
    • 2016-09-17
    • 2021-05-04
    • 2017-02-23
    • 2019-05-04
    相关资源
    最近更新 更多