I am trying to use react-openidconnect. Its my first touch with OAuth and OpenIdConnect. I did everything as in example (https://www.npmjs.com/package/react-openidconnect) but i have no idea how to redirect to login page provided by Auth Server. I tried to google it, but didn't find anything.
2 Answers
Usually you either redirect as a result of one of these actions:
- Clicking a login button
- As a result of not having a valid access token and being able to call an API
In both cases you issue an Authorize Redirect by calling userManager.signInRedirect. See this class for an example, from an introductory SPA code sample of mine that you can run.
Comments
The JSX that is set in renderNotAuthenticated (so e.g. the <div>You are not authenticated, please click here to authenticate.</div> in the docs) is rendered inside a clickable div element (see the source for details), so you should be redirected with a click on that.
In case you don't get redirected, you should see an error in the browser's console.