score:13
generally i recommend this library - which is probably the most respected option out there: https://github.com/identitymodel/oidc-client-js
you can set endpoints explicitly if needed if you have no discovery endpoint. however, it will depend a little on your oauth2 provider capabilities.
see also this sample: https://github.com/skoruba/react-oidc-client-js
2021 update
there have been 2 changes in recent times that impact my previous answer, meaning the above options are no longer the optimal choice:
- more recent browser cookies (samesite=strict) are considered stronger
- browsers drop 3rd party cookies in some parts of the spa flow, eg when renewing tokens via a hidden iframe
these days the preferred solution is to involve an api in the oauth work, to solve these problems. it is a little tricky to understand, but these resources show how, without impacting other parts of the spa architecture:
Source: stackoverflow.com
Related Query
- How to implement the OAuth2 Authorization code grant with PKCE for a React single page application?
- How to implement Drop down in React JS using Array for the below snippet of code
- How to implement componentDidMount with hooks in React to be in line with the EsLint rule "react-hooks/exhaustive-deps": "warn"?
- React Native start failed with error code -4094 how to solve this ONCE for ALL?
- ReactJS - How can I implement pagination for react with keep state when route change?
- How to apply react-native-linear-gradient for the entire app background with React Native
- page title not available with jest/enzyme for testing react app, how to get the title?
- How to get full test coverage for the react code
- How to reuse the same Redux Saga for multiple React components with their own state?
- How to pass input values from a child Form component to the state of its parent component for submission with react hooks?
- How do I hide the source code when deploying react app with firebase?
- How to rewrite code in order for the code to be dry in react
- React application hosted in S3 bucket with OKTA OIDC Authorization grant with PKCE flow (AuthSdk error)
- Trying to implement a React "Lazy" route for code splitting with React Route and Webpack
- How can I implement authentication with next-iron-session using getServerSideProps without including the same code on each page
- How to implement authorization code flow in single page application?
- How to setup a generic interface for the state when using React useReducer with typescript
- How to use the react spring hook with react. Basic code not working
- Code design for the multidocument tabbed interface for React SPA with react-router/react-router-dom?
- How to implement a dynamic reducer creator for API service call in React with Redux project?
- How to update react state with dropdown menu selection? I am using semantic UI for the dropdown
- How to implement React App navigation for VSCode extension with webview
- React useState: How can I update my useState with onChange for input and OnClick for the button?
- How can I create multiple instances of a React component (having an infinite animation) with different values for the :root variables
- How do I implement a functional so that you can interact with the form only once for each user?
- How do I run react and express with a single server.js file listening to a single port for production?
- How to implement SSR for an already built react app with CRA?
- How to maintain a single dockerfile for all the environments for react js?
- How can I change css for the React code depending on the Redux state (true or false)
- How can I show sorting icons all the time and with blue color for current sorting column in react material-table
More Query from same tag
- Why is axios waiting for the previous request before executing the next one
- How to clean the browser cache, each time a new version of the web application is deployed?
- Google Cloud: Storage and App Engine
- listitem onclick material ui giving an error
- show action button based on role reactjs
- React Native show multiple images
- Why Data disappear after refreshing React JS - Firebase?
- displayed value in functional component inside return
- Destructuring and passing in full object simultaenously
- execute child_process in a electron + react application
- How to change the value using data object in code mirror
- useParams getting 0 in console log but correct id in url while I am trying to edit in my curd react app
- Add unique elements to array
- Problem with loop fetching and returing response
- Add script tag and functions to next js?
- @apollo/client (react) Add an array of Objects to a mutation
- for kotlin/js project conversion i'm getting type mismatch: inferred type is yyy but zindex? was expected
- The problem 'state value is changed to undefined when Redux action is called'
- Change react hook state from parent component
- React this.props.match is undefined
- Test for presence/absence of hidden field with jest
- Cannot read properties of undefined (reading 'updateProfile')
- Background size cover not working on longer pages on mobile
- Best practice to send object array to component in React?
- What's the right way to change the state of another component in React
- Displaying errors simultaneously writing in an input
- How to save a nested object in state in React?
- Suggestion list doesn't update correctly after adding new element using react
- Can't seem to use Aliases for importing in Webpack 5
- Inherit autocomplete/suggestion proptypes in wrapper component