MHarisMumtaz / Ng6-Okta-Auth-lib

Okta integeration with angular 6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ng6OktaAuthLibApp

version 0.0.1 Okta integeration with angular 6

Exposed Api's/Services

Ng6OktaAuthService Ng6OktaTokenService

Git Repository

https://github.com/MHarisMumtaz/Ng6-Okta-Auth-lib

npm Package

https://www.npmjs.com/package/ngx-okta-auth-lib

This project was generated with Angular CLI version 6.0.5.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

INSTALLATION

npm install @okta/okta-auth-js
npm install ngx-okta-auth-lib

#USAGE

import NgxOktaAuthLibModule in your app module

import { NgxOktaAuthLibModule } from 'ngx-okta-auth-lib';

  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
       NgxOktaAuthLibModule.forRoot({
        tokenManager : {
          storage  : 'localStorage'
        },
        clientId   : '{oktaClientID}',
        redirectUri: '{RedirectURI}',
        issuer     : '{issureURL}',
        url        : '{UserURL}',
        scope      : 'openid email'
    }),
    RouterModule.forRoot(appRoutes)
  ],
  providers: [],
  bootstrap: [AppComponent]
}) 

import and Add callback component on routing

const appRoutes: Routes = [
  { path: 'implicit/callback', component: NgxOktaCallbackComponent}
]

Add oktaAuthGuard on your components

const appRoutes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: 'implicit/callback', component: NgxOktaCallbackComponent},
  { path: 'home', component: HomeComponent, canActivate: [ NgxOktaAuthGuard ] }
]

About

Okta integeration with angular 6

License:MIT License


Languages

Language:TypeScript 77.9%Language:JavaScript 13.8%Language:HTML 7.9%Language:CSS 0.4%