我想刪除一個基於id的用戶,在auth0 API v2上他們只給出curl命令。對於post方法,我設法將其修改爲angular2 http post,出於某種原因,我無法弄清楚如何使用刪除請求。用Auth0刪除用戶apiv2
的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());
}
Avram,很高興你整理出來!已經下降了一個快速的「答案」,建議一個簡單的方法來獲取模板代碼。 – arcseldon
或者您可以創建一個單例令牌生成方法,以在應用程序中使用相同的令牌。 –