{"id":15062146,"url":"https://github.com/zurfyx/angular2-http-auth","last_synced_at":"2026-01-02T12:49:51.720Z","repository":{"id":57179592,"uuid":"91339708","full_name":"zurfyx/angular2-http-auth","owner":"zurfyx","description":"Angular 5 authenticated HTTP requests.","archived":false,"fork":false,"pushed_at":"2017-12-11T10:29:50.000Z","size":865,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T02:36:12.399Z","etag":null,"topics":["angular","angular5","auth","http"],"latest_commit_sha":null,"homepage":"https://zurfyx.github.io/angular2-http-auth","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/zurfyx.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":"2017-05-15T13:14:56.000Z","updated_at":"2023-05-08T13:25:35.000Z","dependencies_parsed_at":"2022-09-14T03:30:40.201Z","dependency_job_id":null,"html_url":"https://github.com/zurfyx/angular2-http-auth","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/zurfyx%2Fangular2-http-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurfyx%2Fangular2-http-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurfyx%2Fangular2-http-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zurfyx%2Fangular2-http-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zurfyx","download_url":"https://codeload.github.com/zurfyx/angular2-http-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725633,"owners_count":20337670,"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","angular5","auth","http"],"created_at":"2024-09-24T23:31:03.721Z","updated_at":"2026-01-02T12:49:51.695Z","avatar_url":"https://github.com/zurfyx.png","language":"TypeScript","readme":"# Angular HTTP Auth\n\n[![npm Version](https://img.shields.io/npm/v/angular2-http-auth.svg)](https://www.npmjs.com/package/angular2-http-auth)\n[![Build Status](https://travis-ci.org/zurfyx/angular2-http-auth.svg?branch=master)](https://travis-ci.org/zurfyx/angular2-http-auth)\n\n\u003e Angular authenticated HTTP requests (no JWT required).\n\nInspired by [angular2-jwt](https://github.com/auth0/angular2-jwt)\n\n## Install\n\n```\nnpm install angular2-http-auth\n```\n\n## Usage\n\n[auth-http.module.ts](https://github.com/zurfyx/angular2-http-auth/blob/master/example/app/auth-http.module.ts)\n\nThis is the configuration file. You can pass it default fixed headers as well as dynamic headers (such as the authorization token).\n\nMake sure to import this module prior doing any authenticated HTTP call.\n\n`app.module.ts` is often a good place to import it.\n\n```\nimport { AuthHttp, AuthConfig } from 'angular2-http-auth';\n\nexport function authHttpServiceFactory(\n  http: Http,\n  tokenIsHereService: OptionalServiceThatProvidesTheAuthorizationToken,\n) {\n  return new AuthHttp(new AuthConfig({\n    headers: {\n      'Content-Type': 'application/json',\n      Authorization: () =\u003e tokenIsHereService.authorizationKey,\n    },\n  }), http);\n}\n\n@NgModule({\n  providers: [\n    {\n      provide: AuthHttp,\n      useFactory: authHttpServiceFactory,\n      deps: [Http, OptionalServiceThatProvidesTheAuthorizationToken]\n    }\n  ]\n})\nexport class AuthHttpModule { }\n```\n\n*It is very similar to [angular2-jwt](https://github.com/auth0/angular2-jwt)'s, even though some parameters might be different.*\n\n[app.module.ts](https://github.com/zurfyx/angular2-http-auth/blob/master/example/app/app.module.ts)\n\n```\nimport { HttpModule } from '@angular/http';\nimport { AuthHttpModule } from './auth-http.module';\n\n@NgModule({\n  imports: [\n    ...\n    HttpModule,\n    AuthHttpModule,\n    ...\n  ],\n```\n\n[my-user-panel.service.ts](https://github.com/zurfyx/angular2-http-auth/blob/master/example/app/app.service.ts)\n\n```\nimport { AuthHttp } from 'angular2-http-auth';\n...\nfetchPrivateStuff(): Observable\u003cResponse\u003e {\n  return this.authHttp.post(`https://my-site.com/privateStuff`, {});\n}\n```\n\n## TODO\n\n* \u003cstrike\u003eDefault headers\u003c/strike\u003e\n* Default search params\n* Default body\n* withCredentials (cookies)\n\n## License\n\nMIT © [Gerard Rovira Sánchez](//zurfyx.com)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzurfyx%2Fangular2-http-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzurfyx%2Fangular2-http-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzurfyx%2Fangular2-http-auth/lists"}