Tyl*_*nes 5 javascript reactjs react-router auth0 react-native
Auth0重定向到http:// localhost:3000/callback#/ acccess-token = dxy
我的反应应用程序中出现了一个空白屏幕.
继承人我的主要app.js
render((
<HashRouter>
<Main />
</HashRouter>
), $('#app')[0]);
Run Code Online (Sandbox Code Playgroud)
我的主要包含我的routes.js组件.
class Routes extends Component {
constructor(props, context) {
super(props, context);
this.state = { mainData: this.props.mainData };
this.handleAuthentication = this.handleAuthentication.bind(this)
}
componentWillReceiveProps(newProps) {
this.setState((previousState) => update(previousState, {
mainData: { $set: newProps.mainData },
}));
}
handleAuthentication(nextState, replace) {
if (/access_token|id_token|error/.test(nextState.location.hash)) {
this.props.auth.handleAuthentication();
}
}
render() {
return (
<div>
<Switch>
<Route path='/callback' render={props => {
this.handleAuthentication(props);
return <Callback {...props} />
}} />
<Route exact path='/' render={props => (
<Dashboard changeAppBar={this.props.changeAppBar} userProfile={this.state.mainData.userProfile} windowHeight={this.props.wh} windowWidth={this.props.ww} />)}
/>
<Route path='/settings' render={props => (
<Settings changeAppBar={this.props.changeAppBar} userProfile={this.state.mainData.userProfile} />)}
/>
</Switch>
</div>
);
}
}
export default Routes;
Run Code Online (Sandbox Code Playgroud)
继承人我的auth0初始
this.auth0 = new auth0.WebAuth({
clientID: 'oiEjW4Mf6Ju4BvRfHeuObQnMbghKs38g',
domain: 'cryptok1ng.auth0.com',
responseType: 'token id_token',
redirectUri: 'http://localhost:3000/callback'
})
Run Code Online (Sandbox Code Playgroud)
一切正常,直到我从auth0重定向回/回调.根本找不到屏幕/路线并且什么都不做.
控制台的屏幕截图./ callback断点永远不会被击中.
感谢任何帮助,我一直在通过文档和答案无济于事.
我假设您在 Auth0 前端客户端配置> 中添加了回调 URi 并将http://localhost:3000/callback
其保存。
另外,在您的callback.html 文件中,您添加了一些标签,以便在令牌经过正确身份验证后显示某些内容。
如果一切正常,但仍然出现空白错误。请发布您的控制台屏幕截图来查看。
归档时间: |
|
查看次数: |
368 次 |
最近记录: |