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;
}
);
}
this module provide us "access_token". Is there any way to use
jwt
instead of this?Is there any module that support
jwt
for django 2social 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.In client side: what is the best way to find what is user role to grant him access to review the routes?