【问题标题】:404 auth0 update user (PUT)404 auth0 更新用户(PUT)
【发布时间】:2015-12-30 04:42:48
【问题描述】:

尝试使用 auth0 发出 PUT 请求时,我一直遇到 404“未找到用户”错误。

我正在尝试更新用户并使用他们的文档告诉我使用的确切端点进行此 API 调用。

当从他们的文档(他们有一个内置测试)拨打电话时,我发送的正文一切正常,我收到了 200 条成功消息。

当我尝试从我的应用程序发出相同的调用时,我不断收到 404 未找到用户错误。

但是,当我使用具有相同 user_id 的相同端点从我的应用程序 GET 时,一切正常(证明我的 cliendID 配置正确)。

为什么会失败?

var updateAuthUser = function(){
    var request = {
        "user_metadata": {
            "springboardID": 100055
        }
    }

    var update = $http.put('https://app36591925.auth0.com/api/v2/users/auth0%7C5606b3c4b0c70b49698612fc', request);

    update.then(function(response) {
            console.log("update success", response);
        }, function(response) {
            console.log("update failure", response);
        });
    return update;
}

工作 GET 请求:

var getAuthUser = function(){
    $http.get('https://app36591925.auth0.com/api/v2/users/auth0|5606b3c4b0c70b49698612fc')
        .then(function(response){
            console.log("response", response);

            var deferred = $q.defer();
            deferred.resolve(response);
            return deferred.promise;
        });
}

【问题讨论】:

    标签: angularjs http-status-code-404 put auth0


    【解决方案1】:

    更新用户的端点将使用 PATCH 调用,而不是 PUT。

    https://auth0.com/docs/api/v2#!/Users/patch_users_by_id

    在这种情况下返回的正确响应是 405 Method Not Allowed,但 hapi 尚不支持这一点。见https://github.com/hapijs/hapi/issues/1534

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 2014-05-27
      相关资源
      最近更新 更多