{"id":20307310,"url":"https://github.com/oktadev/okta-react-login-example","last_synced_at":"2025-04-11T15:11:22.709Z","repository":{"id":50140945,"uuid":"316059850","full_name":"oktadev/okta-react-login-example","owner":"oktadev","description":"A React Login Example with Hosted Login, Sign-In Widget, and Auth JS","archived":false,"fork":false,"pushed_at":"2021-06-02T19:43:08.000Z","size":466,"stargazers_count":8,"open_issues_count":0,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-25T11:21:21.454Z","etag":null,"topics":["login","oidc","react","reactjs"],"latest_commit_sha":null,"homepage":"https://developer.okta.com/blog/2020/12/16/react-login","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oktadev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-25T21:42:27.000Z","updated_at":"2023-05-02T22:18:40.000Z","dependencies_parsed_at":"2022-09-01T12:40:59.191Z","dependency_job_id":null,"html_url":"https://github.com/oktadev/okta-react-login-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-react-login-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-react-login-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-react-login-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-react-login-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oktadev","download_url":"https://codeload.github.com/oktadev/okta-react-login-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429110,"owners_count":21101783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["login","oidc","react","reactjs"],"created_at":"2024-11-14T17:17:10.820Z","updated_at":"2025-04-11T15:11:22.685Z","avatar_url":"https://github.com/oktadev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Login Examples\n\nThis repository contains three different login examples (Okta-hosted, Sign-In Widget, and custom login form). Please read [A Quick Guide to React Login Options](https://developer.okta.com/blog/2020/12/16/react-login) to see how it was created.\n\n**Prerequisites:**\n\n- [Node 14](https://nodejs.org/)\n- [Okta CLI 0.7.1+](https://github.com/okta/okta-cli)\n\n\u003e [Okta](https://developer.okta.com/) has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.\n\n* [Getting Started](#getting-started)\n* [Links](#links)\n* [Help](#help)\n* [License](#license)\n\n## Getting Started\n\nTo run this example, run the following commands:\n\n```bash\ngit clone https://github.com/oktadeveloper/okta-react-login-example.git\ncd okta-react-login-example\n```\n\n### Create the OIDC Application in Okta\n\nRegister for a free developer account with the following simple commands using the [Okta CLI](https://github.com/okta/okta-cli), in the project root folder:\n\n```shell\nokta register\n```\n\nProvide the required information. Once you register, create a client application in Okta with the following command:\n\n```shell\nokta apps create\n```\n\nYou will be prompted to select the following options:\n- Type of Application: **2: SPA**\n- Redirect URI: `http://localhost:3000/callback`\n- Logout Redirect URI: `http://localhost:3000`\n\nThe application configuration will be printed to your screen:\n\n```shell\nOkta application configuration:\nIssuer:    https://dev-133320.okta.com/oauth2/default\nClient ID: 0oa5qedkihI7QcSoi357\n```\n\nReplace the values in `src/App.js` with these values.\n\n```js\nconst oktaAuth = new OktaAuth({\n  issuer: 'https://{yourOktaDomain}/oauth2/default',\n  clientId: '{yourClientID}',\n  redirectUri: window.location.origin + '/callback'\n});\n```\n\nYou'll also need to update `src/OktaSignInWidget.js` with your client ID.\n\n```js\nthis.oktaAuth = new OktaAuth({\n  issuer: props.baseUrl,\n  clientId: '{yourClientID}',\n  pkce: true\n});\n```\n\nFinally, you'll need to update `src/Login.js` with your Okta domain.\n\n```js\n  return authState.isAuthenticated ?\n    \u003cRedirect to={{ pathname: '/' }}/\u003e :\n    \u003cOktaSignInWidget\n      baseUrl='https://{yourOktaDomain}'\n      onSuccess={onSuccess}\n      onError={onError}/\u003e;\n```\n\nIf you haven't done so already, install the dependencies.\n\n```shell\nnpm install\n```\n\nStart your app and you should be able to log in.\n\n```shell\nnpm start\n```\n\nThis example uses Okta Auth JS and gives you full customization of your login form. The [blog post](https://developer.okta.com/blog/2020/12/16/react-login) also shows how to implement Okta-hosted login and login with the Okta Sign-In Widget.\n\nYou can find the code for those in the [`okta-hosted`](https://github.com/oktadeveloper/okta-react-login-example/tree/okta-hosted) and [`sign-in-widget`](https://github.com/oktadeveloper/okta-react-login-example/tree/sign-in-widget) branches.\n\n## Links\n\nThis example uses the following open source libraries from Okta:\n\n* [Okta React SDK](https://github.com/okta/okta-react)\n* [Okta SignIn Widget](https://github.com/okta/okta-signin-widget)\n* [Okta Auth JS SDK](https://github.com/okta/okta-auth-js)\n* [Okta CLI](https://github.com/okta/okta-cli)\n\n## Help\n\nPlease post any questions as comments on the [blog post](https://developer.okta.com/blog/2020/12/16/react-login), or visit our [Okta Developer Forums](https://devforum.okta.com/).\n\n## License\n\nApache 2.0, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fokta-react-login-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktadev%2Fokta-react-login-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fokta-react-login-example/lists"}