4

I' m working on django rest framework (django 2) for the backend with angular 5 for the client. I'm using this module for social auth.

I have some important questions about it and my code below.

From documentation we must send client_id, secret_id and client secret and user and password to this URL http://localhost:8000/auth/token and in return, it will give us the access_token. So we should have secret_id and client_id in client side... is it safe to keep this data there? If not, what is the correct way?

  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;
        }
      );
  }
  1. this module provide us "access_token". Is there any way to use jwt instead of this?

  2. Is there any module that support jwt for django 2 social auth? By default I searched many times for it but all packages are for django 1.1. If you know something better please tell me.

  3. In client side: what is the best way to find what is user role to grant him access to review the routes?

ucMedia
  • 4,105
  • 4
  • 38
  • 46
devmrh
  • 1,171
  • 4
  • 19
  • 46
  • Enlighten us a bit with text and ref how you tried to your questions solved. It improves the question and motivates other to help you faster. – ZF007 Mar 18 '18 at 11:58
  • i tried to improve my question . thanks – devmrh Mar 18 '18 at 12:15
  • Well done. I can see you did your best. as you can see I've made some edits to improve the question even more ;-) Hope it gets answered for you soon. GL. – ZF007 Mar 18 '18 at 12:40

0 Answers0