# @ebondu/angular2-keycloak

Latest version **1.8.6** (published 2026-02-03) · Apache2 license · 0 weekly downloads

## Install

```sh
npm install @ebondu/angular2-keycloak
pnpm add @ebondu/angular2-keycloak
yarn add @ebondu/angular2-keycloak
bun add @ebondu/angular2-keycloak
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.8.6 |
| Published | 2026-02-03 |
| First published | 2017-01-26 |
| Weekly downloads | 0 |
| License | Apache2 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 205.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | ebondu |
| Maintainers | ebondu |
| Keywords | angular, angular21, Keycloak, typescript |

## Links

- npm: https://www.npmjs.com/package/@ebondu/angular2-keycloak
- Repository: https://github.com/ebondu/angular2-keycloak
- Homepage: https://github.com/ebondu/angular2-keycloak#readme
- Issues: https://github.com/ebondu/angular2-keycloak.git/issues
- npm.io page: https://npm.io/package/@ebondu/angular2-keycloak

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) 2.8.1

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.8.6 (latest) — 2026-02-03
- 0.2.0 (beta) — 2017-01-26
- 1.8.5 — 2026-01-29
- 1.8.4 — 2025-12-10
- 1.8.3 — 2025-06-12
- 1.8.2 — 2025-06-12
- 1.8.1 — 2024-11-25
- 1.8.0 — 2024-10-24
- 1.7.2 — 2024-10-24
- 1.7.1 — 2024-10-16
- 1.7.0 — 2023-09-19
- 1.6.2 — 2023-06-16
- 1.6.1 — 2023-01-16
- 1.6.0 — 2022-09-21
- 1.5.3 — 2022-08-09
- … 34 more at https://npm.io/package/@ebondu/angular2-keycloak/versions

## README

# angular2-keycloak

Native Typescript Keycloak library for angular2/4.

## Installation

To install this library, run:

```bash
$ npm install @ebondu/angular2-keycloak --save
```

## Development

To generate all `*.js`, `*.js.map` and `*.d.ts` files:

```bash
$ npm run tsc
```

To lint all `*.ts` files:

```bash
$ npm run lint
```

## Usage

Declare Keycloak module in angular app :

```javascript
import { Ng2KeycloakModule } from '@ebondu/angular2-keycloak';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    Ng2KeycloakModule
  ],
  providers: [
    ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }


```

To login

```javascript
import { Keycloak } from '@ebondu/angular2-keycloak';
...

export class MyLoginClass implements OnInit {

  public parsedToken: any;
  public isAuthenticated: boolean;
  public profile: any;

  constructor( private keycloak: Keycloak) {
    Keycloak.authenticatedObs.subscribe(auth => {
      this.isAuthenticated = auth;
      this.parsedToken = Keycloak.tokenParsed;

      console.info('APP: authentication status changed...');
    });
    this.keycloak.init({});
  }

  ngOnInit() {
    // Configure the Keycloak
    Keycloak.config = 'assets/keycloak.json';

    // Initialise the Keycloak
    this.keycloak.init({
      checkLoginIframe: false
    });
  }

  login() {
    Keycloak.login({});
  }

  logout() {
    Keycloak.logout({});
  }

  loadProfile() {
    Keycloak.loadUserProfile().subscribe(profile => {
      this.profile = profile;
    });
  }

  ...
}
```

Please, use Http interface to get access to Keycloak http proxy (authentication / authorization). 
Angular will inject the right provider class for you.

```javascript
import { Http } from '@angular/http';
...

@Injectable()
export class MyClass {
    // Angualar will inject the instance of the KeycloakHttp class
    constructor(private http: Http) {}

    callAPI(): Observable<MyObject> {

      let headers = new Headers({'Accept' :'application/json'});
      let options: RequestOptionsArgs = { headers: headers };
        return this.http.get("http://localhost/myAPI/myMethod",  options)
            .map(res => res.json())
            .catch(err => handleError(err));
     }
     ...
}
```

## Example

See [`angular2-webpack-product-app`](https://github.com/ebondu/angular2-keycloak/blob/master/example/angular2-webpack-product-app)

## License

Apache2 © [ebondu](dev.ebondu@gmail.com)
# angular2-keycloak

---
_Source: https://npm.io/package/@ebondu/angular2-keycloak · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
