尝试使用 auth0 发出 PUT 请求时,我不断遇到 404“找不到用户”错误。
我正在尝试更新用户,并使用他们的文档告诉我使用的确切端点进行此 API 调用。
当从他们的文档中进行调用时(他们有内置测试),我发送的正文一切正常,并且我收到了 200 成功消息。
当我尝试从我的应用程序进行相同的调用时,我不断收到 404 用户未找到错误。
但是,当我使用具有相同 user_id
的相同端点从我的应用程序获取时,一切正常(证明我的 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;
});
}
最佳答案
更新用户的端点将使用 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 .
关于angularjs - 404 auth0 更新用户(PUT),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32899247/