我正在使用带有锁版本10.8的Angular 2,我正在尝试添加用户更改密码的功能。我尝试过以下方法,该方法调用Management API,其中参数user_id
是从用户的Auth0配置文件接收的user_id
,参数connection
是'Username-Password-Authentication'
public resetPassword(user_id: string, password: string, connection: string): Observable<any> {
let body = JSON.stringify({ password, connection });
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.authHttp.patch('https://https://manage.auth0.com/api/v2/users/' + user_id, body, options).map(response => {
return response.json();
}).catch(this.appService.handleError);
}
使用此代码时,出现以下错误:
OPTIONS https://https//manage.auth0.com/api/v2/users/auth0%7C58b77f281667c9685d1019c3 净:: ERR_NAME_NOT_RESOLVED
我在这里做错了什么?
以下是我使用的两个来源:
https://auth0.com/docs/connections/database/password-change
https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
是的,&#34;更改密码流v2&#34;切换已启用。
答案 0 :(得分:1)
替换'https://https://manage.auth0.com/api/v2/users/'
使用'https://manage.auth0.com/api/v2/users/'
在您的补丁请求中。
该协议在网址中重复两次。
修改强>
您还需要更换&#39; manage&#39;使用您的Auth0帐户名https://<account>.auth0.com/api/v2/users/
。
您可以转到https://manage.auth0.com/#/apis,点击Auth0 Management API
链接,然后点击设置identifier
字段。这应该是您请求的基本网址。
另外,请务必在Auth0信息中心检查客户端设置中的http://localhost:3000
字段中是否有Allowed Origins (CORS)
。