{"id":26179599,"url":"https://github.com/bezkoder/angular-12-jwt-authentication","last_synced_at":"2025-04-14T22:36:13.532Z","repository":{"id":101823906,"uuid":"373039613","full_name":"bezkoder/angular-12-jwt-authentication","owner":"bezkoder","description":"Angular 12 JWT - Token based Authentication \u0026 Role based Authorization example with Web Api - Login Page \u0026 Registration","archived":false,"fork":false,"pushed_at":"2022-09-01T22:43:38.000Z","size":181,"stargazers_count":59,"open_issues_count":0,"forks_count":60,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T10:47:41.930Z","etag":null,"topics":["angular","angular12","authorization","jwt","jwt-auth","jwt-authentication"],"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/bezkoder.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":"2021-06-02T04:32:00.000Z","updated_at":"2024-10-28T12:21:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"84d6366c-8a4e-4826-94b4-85a92622a069","html_url":"https://github.com/bezkoder/angular-12-jwt-authentication","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/bezkoder%2Fangular-12-jwt-authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezkoder%2Fangular-12-jwt-authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezkoder%2Fangular-12-jwt-authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezkoder%2Fangular-12-jwt-authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bezkoder","download_url":"https://codeload.github.com/bezkoder/angular-12-jwt-authentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248974646,"owners_count":21192186,"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","angular12","authorization","jwt","jwt-auth","jwt-authentication"],"created_at":"2025-03-11T21:50:38.410Z","updated_at":"2025-04-14T22:36:13.526Z","avatar_url":"https://github.com/bezkoder.png","language":"TypeScript","readme":"# Angular 12 JWT Authentication \u0026 Authorization example\n\n## Flow for User Registration and User Login\nFor JWT – Token based Authentication with Web API, we’re gonna call 2 endpoints:\n- POST `api/auth/signup` for User Registration\n- POST `api/auth/signin` for User Login\n\nYou can take a look at following flow to have an overview of Requests and Responses that Angular 12 Client will make or receive.\n\n![angular-12-jwt-authentication-flow](angular-12-jwt-authentication-flow.png)\n\n## Angular JWT App Diagram with Router and HttpInterceptor\n![angular-12-jwt-authentication-overview](angular-12-jwt-authentication-overview.png)\n\nFor more detail, please visit:\n\u003e [Angular 12 JWT Authentication \u0026 Authorization with Web API](https://bezkoder.com/angular-12-jwt-auth/)\n\n## With Spring Boot back-end\n\n\u003e [Angular 12 + Spring Boot: JWT Authentication and Authorization example](https://bezkoder.com/angular-12-spring-boot-jwt-auth/)\n\n## With Node.js Express back-end\n\n\u003e [Angular 12 + Node.js Express: JWT Authentication and Authorization example](https://bezkoder.com/node-js-angular-12-jwt-auth/)\n\nOpen `app/_helpers/auth.interceptor.js`, modify the code to work with **x-access-token** like this:\n```js\n...\n\n// const TOKEN_HEADER_KEY = 'Authorization'; // for Spring Boot back-end\nconst TOKEN_HEADER_KEY = 'x-access-token';   // for Node.js Express back-end\n\n@Injectable()\nexport class AuthInterceptor implements HttpInterceptor {\n  ...\n\n  intercept(req: HttpRequest\u003cany\u003e, next: HttpHandler): Observable\u003cHttpEvent\u003cany\u003e\u003e {\n    ...\n    if (token != null) {\n      // for Spring Boot back-end\n      // authReq = req.clone({ headers: req.headers.set(TOKEN_HEADER_KEY, 'Bearer ' + token) });\n\n      // for Node.js Express back-end\n      authReq = req.clone({ headers: req.headers.set(TOKEN_HEADER_KEY, token) });\n    }\n    return next.handle(authReq);\n  }\n}\n\n...\n```\n\nRun `ng serve --port 8081` for a dev server. Navigate to `http://localhost:8081/`.\n\n## More practice\n\u003e [Angular JWT Refresh Token example with Http Interceptor](https://www.bezkoder.com/angular-12-refresh-token/)\n\n\u003e [Angular CRUD Application example with Web API](https://bezkoder.com/angular-12-crud-app/)\n\n\u003e [Angular Pagination example | ngx-pagination](https://bezkoder.com/angular-12-pagination-ngx/)\n\n\u003e [Angular File upload example with progress bar \u0026 Bootstrap](https://bezkoder.com/angular-12-file-upload/)\n\nFullstack with Node.js Express:\n\u003e [Angular + Node.js Express + MySQL example](https://bezkoder.com/angular-12-node-js-express-mysql/)\n\n\u003e [Angular + Node.js Express + PostgreSQL example](https://bezkoder.com/angular-12-node-js-express-postgresql/)\n\n\u003e [Angular + Node.js Express + MongoDB example](https://bezkoder.com/angular-12-mongodb-node-js-express/)\n\n\u003e [Angular + Node.js Express: File upload example](https://bezkoder.com/angular-12-node-js-file-upload/)\n\nFullstack with Spring Boot:\n\u003e [Angular + Spring Boot + MySQL example](https://bezkoder.com/angular-12-spring-boot-mysql/)\n\n\u003e [Angular + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-12-spring-boot-postgresql/)\n\n\u003e [Angular + Spring Boot + MongoDB example](https://bezkoder.com/angular-12-spring-boot-mongodb/)\n\n\u003e [Angular + Spring Boot: File upload example](https://bezkoder.com/angular-12-spring-boot-file-upload/)\n\nFullstack with Django:\n\u003e [Angular 12 + Django example](https://bezkoder.com/django-angular-12-crud-rest-framework/)\n\n\u003e [Angular + Django + MySQL](https://bezkoder.com/django-angular-mysql/)\n\n\u003e [Angular + Django + PostgreSQL](https://bezkoder.com/django-angular-postgresql/)\n\n\u003e [Angular + Django + MongoDB](https://bezkoder.com/django-angular-mongodb/)\n\nServerless with Firebase:\n\u003e [Angular 12 Firebase CRUD with Realtime DataBase | AngularFireDatabase](https://bezkoder.com/angular-12-firebase-crud/)\n\n\u003e [Angular 12 Firestore CRUD example with AngularFireStore](https://bezkoder.com/angular-12-firestore-crud-angularfirestore/)\n\n\u003e [Angular 12 Firebase Storage: File Upload/Display/Delete example](https://bezkoder.com/angular-12-file-upload-firebase-storage/)\n\nIntegration (run back-end \u0026 front-end on same server/port)\n\u003e [How to integrate Angular with Node.js Restful Services](https://bezkoder.com/integrate-angular-12-node-js/)\n\n\u003e [How to Integrate Angular with Spring Boot Rest API](https://bezkoder.com/integrate-angular-12-spring-boot/)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbezkoder%2Fangular-12-jwt-authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbezkoder%2Fangular-12-jwt-authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbezkoder%2Fangular-12-jwt-authentication/lists"}