redux-implicit-oauth2
OAuth 2.0 Implicit Grant Flow with Redux.
Example (with React)
The following example displays either a login or logout button depending on the state. Set the config object according to your OAuth 2.0 server parameters. The redirect callback page should be on the same site as the rest of your app.
import React from 'react'import PropTypes from 'prop-types'import connect from 'react-redux'import login logout from 'redux-implicit-oauth2' const config = url: "https://example.com/authorize" client: "some_client_id" redirect: "https://example.com/callback.html" scope: "some_scope" width: 400 // Width (in pixels) of login popup window. Optional, default: 400 height: 400 // Height (in pixels) of login popup window. Optional, default: 400 const Login = isLoggedIn login logout if isLoggedIn return <button ='button' =>Logout</button> else return <button ='button' =>Login</button> LoginpropTypes = isLoggedIn: PropTypesboolisRequired login: PropTypesfuncisRequired logout: PropTypesfuncisRequired const mapStateToProps = auth isLoggedIn: authisLoggedIn const mapDispatchToProps = logout mapStateToProps mapDispatchToPropsLogin
Don't forget to add the reducer and middleware to your Redux store:
const configureStore =