【问题标题】:Restangular - Client_credentials grant type not supported?Restangular - 不支持 Client_credentials 授权类型?
【发布时间】:2016-08-31 05:27:53
【问题描述】:

下面的代码不起作用。授予类型是“client_credentials”。它返回状态为 -1 的空响应。 API没问题。这两个请求在邮递员上都可以正常工作

function authentication(user) {
            return Restangular
                .all('token')
                .post('grant_type=client_credentials&client_id=' + APPLICATION.clientId + '&client_secret=' + 'XYZ',
                undefined, { 'Content-Type': 'application/x-www-form-urlencoded' });
        }

下面的代码与“密码”授权类型完美配合。

function authentication(user) {
            return Restangular
                .all('token')
                .post('grant_type=password&username=' + user.username + '&password=' + user.password + '&client_id=' + APPLICATION.clientId,
                undefined, { 'Content-Type': 'application/x-www-form-urlencoded' });
        }

怎么了?

【问题讨论】:

    标签: javascript angularjs oauth oauth-2.0 restangular


    【解决方案1】:

    您似乎使用相同的client_id 进行这些调用。第二个工作示例显示客户端是所谓的“公共客户端”,因为它无需身份验证即可识别自己。您的第一个示例需要一个机密客户端,因为客户端需要在client_credentials 流中对自己进行身份验证。两者不能混合,所以看起来您的客户端在授权服务器上注册为公共客户端,因此根据定义它不能使用客户端凭据授予类型。

    【讨论】:

      猜你喜欢
      • 2017-05-14
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      • 2017-07-27
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多