ReactJS Authentication Tutorial, Part 3
In the third and final part of our series, we look at how ReactJS can be used with Auth0 to create authentication requests from your users.
Join the DZone community and get the full member experience.Join For Free
Welcome back! If you missed Part 1 or Part 2, follow the links to check them out!.
Login to your Auth0 management dashboard Chuck Norris World API and for the identifier, I'll set it as  We'll leave the signing algorithm as RS256 and click on the Create API button.
Creating the Chuck Norris Charlie Sheen think he is winning. Chuck won a long time ago." }, { id: 88883, joke: 'Everything King Midas touches turnes to gold. Everything Chuck Norris touches turns up dead.' }, { id: 88884, joke: 'Each time you rate this, Chuck Norris hits Obama with Charlie Sheen and says, "Who is winning now?!"' }, { id: 88885, joke: "For Charlie Sheen winning is just wishful thinking. For Chuck Norris it's a way of life." }, { id: 88886, joke: "Hellen Keller's favorite color is Chuck Norris." } ]; res.json(CelebrityJokes); }) app.listen(3333); console.log('Listening on localhost:3333');directory.); } a hosted version of Auth0 Lock in the
loginmethod}.like in users.
Let's go update the
Nav component to hide/show the
login andChuck Norris World</Link> </div> <ul className="nav navbar-nav"> <li> <Link to="/">Food Jokes</Link> </li> <li> { ('; import { getFoodData } from '../utils/chucknorris-api'; class FoodJokes extends Component { constructor() { super() this.state = { jokes: [] }; } getFoodJokes() { getFoodData().then((jokes) => { this.setState({ jokes }); }); } componentDidMount() { this.getFoodJokes(); } render() { const { jokes } = this.state; return ( <div> <Nav /> <h3 className="text-center">Chuck Norris Food Jokes</h3> <hr/> { jokes.map((joke, index) => ( <div className="col-sm-6" key={index}> <div className="panel panel-primary"> <div className="panel-heading"> <h3 className="panel-title"> <span className="btn">#{ joke.id }</span></h3> </div> <div className="panel-body"> <p> { joke.joke } </p> </div> </div> </div> ))} <div className="col-sm-12"> {.
access_token and
id_token.
import { Component } from 'react'; import { setIdToken, setAccessToken } from '../utils/AuthService'; class Callback extends Component { constructor() { super() } componentDidMount() { setAccessToken(); setIdToken(); window.location.href = "/"; } render() { return null; } } export default Callback;
Callback.js.
Hosted Lock Login Widget.
If you enjoyed this article and want to learn more about React, check out this collection of tutorials and articles on all things React.
Published at DZone with permission of Prosper Otemuyiwa, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.