Hi, I’m trying to implement ionic Auth in an Ionic2 project
I added the app_id to my app.module.ts and load it via CloudModule.forRoot(cloudSettings).
(https://docs.ionic.io/setup.html#configuration)
That’s the stacktrace:
error_handler.js:51 TypeError: Cannot read property ‘config’ of undefined
at Auth (auth.js:73)
at new Auth (index.js:43)
at NgModuleInjector.get (AppModule.ngfactory.js:311)
at NgModuleInjector.AppModuleInjector.getInternal (AppModule.ngfactory.js:473)
at NgModuleInjector.get (ng_module_factory.js:94)
at ElementInjector.get (element_injector.js:29)
at ElementInjector.get (element_injector.js:29)
at ElementInjector.get (element_injector.js:29)
at ReflectiveInjector_.getByKeyDefault (reflective_injector.js:786)
at ReflectiveInjector._getByKey (reflective_injector.js:752)
TypeError: Cannot read property 'config' of undefined
at GoogleAuth.NativeAuth (webpack:///XXX/~/@ionic/cloud/dist/esm/auth.js:460:0 <- src/test.ts:68536:27)
at GoogleAuth [as constructor] (webpack:///XXX/~/@ionic/cloud/dist/esm/auth.js:491:0 <- src/test.ts:68567:16)
at new GoogleAuth (webpack:///XXX/~/@ionic/cloud-angular/dist/es5/index.js:56:0 <- src/test.ts:67865:16)
at DynamicTestModuleInjector.get (/DynamicTestModule/module.ngfactory.js:280:65)
at DynamicTestModuleInjector.getInternal (/DynamicTestModule/module.ngfactory.js:381:50)
at DynamicTestModuleInjector.NgModuleInjector.get (webpack:///XXX/~/@angular/core/src/linker/ng_module_factory.js:94:0 <- src/test.ts:6412
I have a problem when Auth was added to the providers[] in app.module.ts. the same as problem you had before
But when I remove it I have another problem
EXCEPTION: Error in :0:0 caused by: No provider for Auth!
main.js:58479 ORIGINAL EXCEPTION: No provider for Auth!
main.js:58482 ORIGINAL STACKTRACE:
main.js:58483 Error: No provider for Auth!
The missing part was, to use Auth in my app.component.ts or login.ts, I needed to import CloudModule in app.modules.ts (see https://github.com/cfjedimaster/Cordova-Examples/blob/master/ionicauth2/src/app/app.module.ts). From the github example the app_id is hardcoded… I imagine it could/should be read from ionic.config.json? But for now I’m just moving forward with this.