我正在尝试为我的 android 应用程序在烧瓶中编写一个基于令牌的身份验证。为此,我需要一个唯一的令牌,我可以使用它来验证用户。
它的危险库提供了一个 JSONWebSignatureSerializer 函数,我可以使用它来创建 JWT 令牌。所以我的第一个问题是,将 JWT 用于基于移动的身份验证是否安全?
其次,我对 django rest 框架如何生成其令牌进行了一些研究。
def generate_key(self):
return binascii.hexlify(os.urandom(20)).decode()
Run Code Online (Sandbox Code Playgroud)
这个令牌是唯一的还是只是一个随机的?我应该使用哪一个进行基于移动的身份验证?
在 python 中为移动应用程序生成唯一令牌的基本方法是什么?
很多时候我们在构造函数中发送props但是我们从不在构造函数中的任何地方使用this.props,所以为什么需要传递它以及何时需要这样做.
class App extends React.Component {
constructor(props) {
super(props); // When do we need to send props to the constructor
this.state = {
data: 'Initial data...'
}
this.updateState = this.updateState.bind(this);
};
updateState(e) {
this.setState({data: e.target.value});
}
render() {
return (
<div>
<input type = "text" value = {this.state.data}
onChange = {this.updateState} />
<h4>{this.state.data}</h4>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)