{"id":15252252,"url":"https://github.com/hwouters/auth0-angular","last_synced_at":"2025-07-30T19:14:02.022Z","repository":{"id":39744109,"uuid":"264503951","full_name":"HWouters/auth0-angular","owner":"HWouters","description":"Angular module using NGRX to authenticate with Auth0","archived":false,"fork":false,"pushed_at":"2024-12-17T18:33:24.000Z","size":3185,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T20:38:14.883Z","etag":null,"topics":["angular","auth0","ngrx"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HWouters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-16T18:45:29.000Z","updated_at":"2025-01-28T03:39:45.000Z","dependencies_parsed_at":"2025-02-18T06:45:14.983Z","dependency_job_id":null,"html_url":"https://github.com/HWouters/auth0-angular","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/HWouters%2Fauth0-angular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWouters%2Fauth0-angular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWouters%2Fauth0-angular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HWouters%2Fauth0-angular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HWouters","download_url":"https://codeload.github.com/HWouters/auth0-angular/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317707,"owners_count":21083528,"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":["angular","auth0","ngrx"],"created_at":"2024-09-29T19:05:29.182Z","updated_at":"2025-04-10T23:50:48.711Z","avatar_url":"https://github.com/HWouters.png","language":"TypeScript","readme":"# @thecla/auth0-angular\n\nAuth0 provides a high quality [Javscript SDK](https://auth0.com/docs/libraries/auth0-spa-js) for authentication in single page applications. However, it's still not a trival task to integrate authentication properly in your own application. This library helps with integrating Auth0 into an Angular application, it:\n\n- Signs the user in on application startup;\n- Uses the Angular router to return to the original page after authentication, preventing unnecessary page reloads;\n- Attaches access tokens to api requests;\n- Provides a guard to protect routes.\n\nThis library is inspired by the NG-Conf 2020 talk from Sam Julien: [The Role of Effects in NgRx Authentication](https://www.ng-conf.org/2020/sessions/rxwut/). It uses [Ngrx Store](https://ngrx.io/guide/store) for managing authentication state and [Ngrx Effects](https://ngrx.io/guide/effects) for authentication orchestration.\n\nThis repo now contains also a library that helps integrating Azure AD B2C authentication in your Angular/Ngrx application.\n\n## Getting Started\n\nStart with an Angular application and the necessary imports for Ngrx:\n\n```js\n// app.module.ts\nStoreModule.forRoot([]),\nEffectsModule.forRoot([]),\n```\n\n### Installation\n\nInstall `@thecla/auth0-angular` and its peer dependency `@auth0/auth0-spa-js`\n\n```sh\nnpm install @auth0/auth0-spa-js\nnpm install @thecla/auth0-angular\n```\n\nFor B2C install install `@thecla/b2c-angular` and its peer dependency `@azure/msal-browser`\n\n```sh\nnpm install @azure/msal-browser\nnpm install @thecla/b2c-angular\n```\n\n### Import and configure module\n\nImport `AuthModule` from `@thecla/auth0-angular` in the app module:\n\n```js\nconst config = {\n  audience: '',\n  domain: '',\n  clientId: '',\n  scope: 'openid profile',\n};\n\nAuthModule.forRoot(config);\n```\n\nor \n\n```js\nconst config = {\n  clientId: '',\n  authority: 'https://{name}.b2clogin.com/{tenantid}',\n  signInPolicy: 'B2C_1A_XXXXXXX',\n  resetPasswordPolicy: 'B2C_1A_XXXXXXX',\n  knownAuthorities: ['{name}.b2clogin.com'],\n  scopes: [],\n};\n\nAuthModule.forRoot(config);\n```\n\n### Sign in\n\nOne way to sign the user in, is to dispatch an `signIn` action:\n\n```js\npublic login() {\n  this.store.dispatch(signIn({ returnUrl: '/' }));\n}\n```\n\nThe return url, is the url where the application will return after authentication.\n\n### Protect route\n\nAnother way is to protect a route with the `AuthGuard`.\n\n```js\nconst routes: Routes = [{ path: 'protected', component: ProtectedComponent, canActivate: [AuthGuard] }];\n```\n\n### Display user info\n\nTo display user information, use `getUser`.\n\n```js\npublic user$ = this.store.pipe(getUser);\n```\n\nThe user object contains the claims from the IdToken.\n\n### Api access\n\nYou don't need to do anything for api access. The library adds automatically a bearer token to each same domain (relative url) requests.\n\n### Sign out\n\nForce a user sign out by dispatching `signOut`:\n\n```js\npublic logout() {\n  this.store.dispatch(signOut());\n}\n```\n\n## Sample application\n\nThis repository contains an example application. After configuring your own Auth0 tenant, it should be ready to go.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwouters%2Fauth0-angular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwouters%2Fauth0-angular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwouters%2Fauth0-angular/lists"}