http用Auth0 apiv2删除用户
http delete user with Auth0 apiv2
我正在尝试根据 id 删除用户,在 auth0 API v2 上他们只提供 curl 命令。对于 post 方法,我设法使其适应 angular2 http post,出于某种原因,我不知道如何使用删除请求。
id 看起来像这样
id = auth0|582b40627882b2970253725c
这是我正在使用的方法:
deleteAuth0User(id){
let headers = new Headers();
headers.append('Authorization', 'Bearer mytoken');
return this.http.delete('https://myusername.eu.auth0.com/api/v2/users/' + id, {headers:headers})
.map(response => response.json());
}
我删除了我的 auth0 用户名和 api 令牌。
结果我得到这个错误:
"{"statusCode":403,"error":"Forbidden","message":"Insufficient scope, expected any of: delete:users,delete:current_user","errorCode":"insufficient_scope"}"
非常感谢任何建议。
谢谢
P.S。如果您对添加新用户的 post 方法感兴趣:
createAuth0User(body){
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'Bearer myapitoken');
return this.http.post('https://myusername.eu.auth0.com/api/v2/users', JSON.stringify(body),{headers:headers})
.map(response => response.json());
}
我设法弄明白了,使用 Auth0 API v2 每次你向范围添加一个选项时都会生成一个新令牌,你可以向范围添加多个选项,这样你就可以使用相同的他们所有人的代币。
关于 http 删除的 Auth0 API v2 的第二件事你不能使用 .map 因为你会得到一个:
json parsing error syntax error unexpected end of input
工作方法是:
deleteAuth0User(id){
let headers = new Headers();
headers.append('Authorization', 'Bearer mytoken');
return this.http.delete('https://myusername.eu.auth0.com/api/v2/users/' + id, {headers:headers})
}
这会起作用,不要忘记在您使用该方法的组件中订阅,因为您仍然会收到回复。
获取所需代码的一种简单方法是使用 Postman。然后您可以简单地将 Curl 命令导入 Postman(使用 import
选项)和/或生成所需的 JavaScript(客户端)/NodeJs 代码(使用 Postman 的 code
选项)。
见下方截图:
和
最后,您可以获得所有 Auth0 的 Authentication API and Management APIv2 端点的预构建模板 Postman 命令。
查看下载选项here
我正在尝试根据 id 删除用户,在 auth0 API v2 上他们只提供 curl 命令。对于 post 方法,我设法使其适应 angular2 http post,出于某种原因,我不知道如何使用删除请求。
id 看起来像这样
id = auth0|582b40627882b2970253725c
这是我正在使用的方法:
deleteAuth0User(id){
let headers = new Headers();
headers.append('Authorization', 'Bearer mytoken');
return this.http.delete('https://myusername.eu.auth0.com/api/v2/users/' + id, {headers:headers})
.map(response => response.json());
}
我删除了我的 auth0 用户名和 api 令牌。
结果我得到这个错误:
"{"statusCode":403,"error":"Forbidden","message":"Insufficient scope, expected any of: delete:users,delete:current_user","errorCode":"insufficient_scope"}"
非常感谢任何建议。 谢谢
P.S。如果您对添加新用户的 post 方法感兴趣:
createAuth0User(body){
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'Bearer myapitoken');
return this.http.post('https://myusername.eu.auth0.com/api/v2/users', JSON.stringify(body),{headers:headers})
.map(response => response.json());
}
我设法弄明白了,使用 Auth0 API v2 每次你向范围添加一个选项时都会生成一个新令牌,你可以向范围添加多个选项,这样你就可以使用相同的他们所有人的代币。
关于 http 删除的 Auth0 API v2 的第二件事你不能使用 .map 因为你会得到一个:
json parsing error syntax error unexpected end of input
工作方法是:
deleteAuth0User(id){
let headers = new Headers();
headers.append('Authorization', 'Bearer mytoken');
return this.http.delete('https://myusername.eu.auth0.com/api/v2/users/' + id, {headers:headers})
}
这会起作用,不要忘记在您使用该方法的组件中订阅,因为您仍然会收到回复。
获取所需代码的一种简单方法是使用 Postman。然后您可以简单地将 Curl 命令导入 Postman(使用 import
选项)和/或生成所需的 JavaScript(客户端)/NodeJs 代码(使用 Postman 的 code
选项)。
见下方截图:
和
最后,您可以获得所有 Auth0 的 Authentication API and Management APIv2 端点的预构建模板 Postman 命令。
查看下载选项here