{"id":13475861,"url":"https://github.com/auth0/angular2-jwt","last_synced_at":"2025-05-14T11:08:31.640Z","repository":{"id":2159284,"uuid":"44948282","full_name":"auth0/angular2-jwt","owner":"auth0","description":"Helper library for handling JWTs in Angular apps","archived":false,"fork":false,"pushed_at":"2024-11-05T05:25:03.000Z","size":2864,"stargazers_count":2638,"open_issues_count":8,"forks_count":481,"subscribers_count":88,"default_branch":"main","last_synced_at":"2025-05-07T10:52:36.770Z","etag":null,"topics":["angular","dx-sdk","jwt"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-10-26T05:37:39.000Z","updated_at":"2025-04-30T12:07:50.000Z","dependencies_parsed_at":"2023-02-19T03:31:07.963Z","dependency_job_id":"e85a9f63-bd3d-40c0-b1c1-6592bde1d4ac","html_url":"https://github.com/auth0/angular2-jwt","commit_stats":{"total_commits":364,"total_committers":96,"mean_commits":"3.7916666666666665","dds":0.7774725274725275,"last_synced_commit":"18d5f2378ca1bbe707bd2b3ff57ec4e150900e89"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fangular2-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fangular2-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fangular2-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2Fangular2-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/angular2-jwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129481,"owners_count":22019628,"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","dx-sdk","jwt"],"created_at":"2024-07-31T16:01:24.183Z","updated_at":"2025-05-14T11:08:31.615Z","avatar_url":"https://github.com/auth0.png","language":"TypeScript","readme":"![Helper library for handling JWTs in Angular applications](https://cdn.auth0.com/website/sdks/banners/angular-jwt-banner.png)\n\n![Release](https://img.shields.io/github/v/release/auth0/angular2-jwt)\n[![codecov](https://codecov.io/gh/auth0/angular2-jwt/branch/main/graph/badge.svg?token=wnauXldcdE)](https://codecov.io/gh/auth0/angular2-jwt)\n![Downloads](https://img.shields.io/npm/dw/@auth0/angular-jwt)\n[![License](https://img.shields.io/:license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)\n[![CircleCI](https://img.shields.io/circleci/build/github/auth0/angular2-jwt)](https://circleci.com/gh/auth0/angular2-jwt)\n\n:books: [Documentation](#documentation) - :rocket: [Getting Started](#getting-started) - :computer: [API Reference](#api-reference) - :speech_balloon: [Feedback](#feedback)\n\n## Documentation\n\n- [Examples](https://github.com/auth0/angular2-jwt/blob/main/EXAMPLES.md) - code samples for common angular-jwt authentication scenario's.\n- [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.\n\nThis library provides an `HttpInterceptor` which automatically attaches a [JSON Web Token](https://jwt.io) to `HttpClient` requests.\n\nThis library does not have any functionality for (or opinion about) implementing user authentication and retrieving JWTs to begin with. Those details will vary depending on your setup, but in most cases, you will use a regular HTTP request to authenticate your users and then save their JWTs in local storage or in a cookie if successful.\n\n## Getting started\n### Requirements\nThis project only supports the [actively supported versions of Angular as stated in the Angular documentation](https://angular.io/guide/releases#actively-supported-versions). Whilst other versions might be compatible they are not actively supported\n\n### Installation\n\n```bash\n# installation with npm\nnpm install @auth0/angular-jwt\n\n# installation with yarn\nyarn add @auth0/angular-jwt\n```\n\n## Configure the SDK\n\nImport the `JwtModule` module and add it to your imports list. Call the `forRoot` method and provide a `tokenGetter` function. You must also add any domains to the `allowedDomains`, that you want to make requests to by specifying an `allowedDomains` array.\n\nBe sure to import the `HttpClientModule` as well.\n\n```ts\nimport { JwtModule } from \"@auth0/angular-jwt\";\nimport { HttpClientModule } from \"@angular/common/http\";\n\nexport function tokenGetter() {\n  return localStorage.getItem(\"access_token\");\n}\n\n@NgModule({\n  bootstrap: [AppComponent],\n  imports: [\n    // ...\n    HttpClientModule,\n    JwtModule.forRoot({\n      config: {\n        tokenGetter: tokenGetter,\n        allowedDomains: [\"example.com\"],\n        disallowedRoutes: [\"http://example.com/examplebadroute/\"],\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nAny requests sent using Angular's `HttpClient` will automatically have a token attached as an `Authorization` header.\n\n```ts\nimport { HttpClient } from \"@angular/common/http\";\n\nexport class AppComponent {\n  constructor(public http: HttpClient) {}\n\n  ping() {\n    this.http.get(\"http://example.com/api/things\").subscribe(\n      (data) =\u003e console.log(data),\n      (err) =\u003e console.log(err)\n    );\n  }\n}\n```\n\n## Using with Standalone Components\nIf you are using `bootstrapApplication` to bootstrap your application using a standalone component, you will need a slightly different way to integrate our SDK:\n\n```ts\nimport { JwtModule } from \"@auth0/angular-jwt\";\nimport { provideHttpClient, withInterceptorsFromDi } from \"@angular/common/http\";\n\nexport function tokenGetter() {\n  return localStorage.getItem(\"access_token\");\n}\n\nbootstrapApplication(AppComponent, {\n    providers: [\n        // ...\n        importProvidersFrom(\n            JwtModule.forRoot({\n                config: {\n                    tokenGetter: tokenGetter,\n                    allowedDomains: [\"example.com\"],\n                    disallowedRoutes: [\"http://example.com/examplebadroute/\"],\n                },\n            }),\n        ),\n        provideHttpClient(\n            withInterceptorsFromDi()\n        ),\n    ],\n});\n```\nAs you can see, the differences are that:\n- The SDK's module is included trough `importProvidersFrom`.\n- In order to use the SDK's interceptor, `provideHttpClient` needs to be called with `withInterceptorsFromDi`.\n\n\n## API reference\nRead [our API reference](https://github.com/auth0/angular2-jwt/blob/main/API.md) to get a better understanding on how to use this SDK.\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n- [This repo's contribution guide](https://github.com/auth0/angular2-jwt/blob/main/CONTRIBUTING.md)\n### Raise an issue\n\nTo provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/angular2-jwt/issues).\n\n### Vulnerability Reporting\n\nPlease do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\"   width=\"150\"\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\"\u003e\n    \u003cimg alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eAuth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout \u003ca href=\"https://auth0.com/why-auth0\"\u003eWhy Auth0?\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\nThis project is licensed under the MIT license. See the \u003ca href=\"https://github.com/auth0/angular2-jwt/blob/main/LICENSE\"\u003e LICENSE\u003c/a\u003e file for more info.\u003c/p\u003e\n","funding_links":[],"categories":["TypeScript","angular","Libraries","API","Awesome Angular [![Awesome TipeIO](https://img.shields.io/badge/Awesome%20Angular-@TipeIO-6C6AE7.svg)](https://github.com/gdi2290/awesome-angular) [![Awesome devarchy.com](https://img.shields.io/badge/Awesome%20Angular-@devarchy.com-86BDC1.svg)](https://github.com/brillout/awesome-angular-components)","Security and Authentication","Uncategorized","Dependencies"],"sub_categories":["JavaScript","Others","Angular \u003ca id=\"angular\"\u003e\u003c/a\u003e","Authentication","Uncategorized","Picker","Helper library"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fangular2-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Fangular2-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Fangular2-jwt/lists"}