Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular django rest框架社会验证oauth2_Angular_Rest_Django Rest Framework_Django Authentication_Django Socialauth - Fatal编程技术网

Angular django rest框架社会验证oauth2

Angular django rest框架社会验证oauth2,angular,rest,django-rest-framework,django-authentication,django-socialauth,Angular,Rest,Django Rest Framework,Django Authentication,Django Socialauth,我正在为后端开发django rest框架(django 2),为客户端开发angular 5。我正在使用社交身份验证的模块 我有一些关于它的重要问题和下面的代码 从文档中,我们必须将客户id、机密id和客户机密以及用户和密码发送到此URLhttp://localhost:8000/auth/token作为回报,它将为我们提供访问令牌。所以我们应该在客户端有秘密id和客户端id。。。将这些数据保存在那里安全吗?如果没有,正确的方法是什么 private client_id = "uvsNRS

我正在为后端开发django rest框架(django 2),为客户端开发angular 5。我正在使用社交身份验证的
模块

我有一些关于它的重要问题和下面的代码

从文档中,我们必须将
客户id
机密id
和客户机密以及用户和密码发送到此URL
http://localhost:8000/auth/token
作为回报,它将为我们提供访问令牌。所以我们应该在客户端有秘密id和客户端id。。。将这些数据保存在那里安全吗?如果没有,正确的方法是什么

  private client_id = "uvsNRS7segoeAY71kLlqxotWx8iUhK2DoRi4ru84";
  private client_secret= "NXpXO1RzfQIHRImDu5LoM2W7ln3VACT6fWSSKQhhAXdBgec8yRTXIC1AlFzMbBiPDBx5e9SaBztf9tSINoJxRpybZXHAtuwYOtDySyJWOmeTkC22JMv64IUr2PUyEjwU";

  onSubmit({value, valid}) {
    if (!valid) {
      console.log("form in invalid!");
    }
    let username = value.username;
    let password = value.password;

    this.http.post<any>("http://localhost:8000/auth/token/", {client_id: this.client_id,client_secret: this.client_secret,grant_type: "password",username : username, password: password})
      .subscribe(
        user => {
          console.log(user)
          if (user && user.access_token) {
            console.log(user)
            localStorage.setItem('token', JSON.stringify(user.access_token));

            this.dialogRef.close(username);
            this.router.navigateByUrl(this.returnUrl);
          }
        }, err => {
          this.error = err.error.non_field_errors;
        }
      );
  }
private client_id=“uvsNRS7segoeAY71kLlqxotWx8iUhK2DoRi4ru84”;
私人客户_secret=“nxpxo1rzfqihrimdu5lom2w7ln3vact6fwsskhhaxdbgec8yrtxic1alfzmbipdbx5e9sabztf9tzinojrpybzxhatuwyotdysyjwometkc22jmv64iur2puyejwu”;
onSubmit({value,valid}){
如果(!有效){
log(“表单无效!”);
}
让username=value.username;
让password=value.password;
这是http.post(“http://localhost:8000/auth/token/“,{client_id:this.client_id,client_secret:this.client_secret,grant_type:“密码”,用户名:用户名,密码:密码})
.订阅(
用户=>{
console.log(用户)
if(用户&&user.access\u令牌){
console.log(用户)
setItem('token',JSON.stringify(user.access_token));
this.dialogRef.close(用户名);
this.router.navigateByUrl(this.returnUrl);
}
},err=>{
this.error=err.error.non\u字段\u错误;
}
);
}
  • 此模块为我们提供“访问令牌”。有没有办法用
    jwt
    来代替这个

  • 是否有任何模块支持django 2
    social auth
    的jwt
  • ?默认情况下,我搜索了很多次,但所有包都是针对django 1.1的。 如果你知道一些更好的,请告诉我

  • 在客户端:找到用户角色授予他查看路由的权限的最佳方法是什么


  • 通过文本和参考您如何尝试解决问题来启发我们。它改进了问题并激励其他人更快地帮助你。我试图改进我的问题。谢谢,我做完了。我看得出你已经尽力了。正如您所看到的,我做了一些编辑,以进一步改进问题;-)希望你能尽快得到答复。德国劳埃德船级社。