version 0.0.1 Okta integeration with angular 6
Ng6OktaAuthService
Ng6OktaTokenService
https://github.com/MHarisMumtaz/Ng6-Okta-Auth-lib
https://www.npmjs.com/package/ngx-okta-auth-lib
This project was generated with Angular CLI version 6.0.5.
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.
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 ] }
]