I am trying to integrate okta with webpack and angular2, I am using almost everything correctly and I end up with error. I am using setup from https://angular.io/resources/zips/webpack/webpack.zip as it is and also followed things correctly mentioned at http://developer.okta.com/blog/2017/03/27/angular-okta-sign-in-widget
i tried to import okta-sign-in.min.js in vendor.ts as well in okta.service.ts with
import '@okta/okta-signin-widget/dist/js/okta-sign-in.min';
file gets imported but still i get OktaSignIn is not defined error
Thanks for any help in advance..
You definitely not following the steps. There's no significance of this line at all.
import '@okta/okta-signin-widget/dist/js/okta-sign-in.min';
okta-sign-in.min is a javascript which needs to be included either in index.html. If you are using angular-cli, then as mentioned in tutorial
"scripts": [
"../node_modules/@okta/okta-signin-widget/dist/js/okta-sign-in.min.js"
],
All steps in tutorial are correctly mentioned.
Step 1: Create 1 service
declare let OktaSignIn: any;
This line will be needed, intialize the constructor here as per need.
Step 2: calling this service in whatevercomponent.component.ts.
step1
import '@okta/okta-signin-widget/dist/js/okta-sign-in.min';
step2:
"scripts": [
"../node_modules/@okta/okta-signin-widget/dist/js/okta-sign-in.min.js"
],
step3:
declare let OktaSignIn: any;
step4:
var Oktasignin=new Oktasignin('okta-signin-widget');
replaced
declare let OktaSignIn: any;
import '@okta/okta-signin-widget/dist/js/okta-sign-in.min';
by
var OktaSignIn = require('@okta/okta-signin-widget');
just read somewhere it happens because of tslint not webpack