Angular-oauth2-oidc: No provider for UrlHelperService! error

Created on 16 Feb 2018  路  4Comments  路  Source: manfredsteyer/angular-oauth2-oidc

Hello,

I am not sure if it is a bug or not however i am getting No provider for UrlHelperService!.

The provider is specified in home.module.ts.
Thank's


HomeComponent_Host.ngfactory.js? [sm]:1 ERROR Error: StaticInjectorError[UrlHelperService]:
StaticInjectorError[UrlHelperService]:
NullInjectorError: No provider for UrlHelperService!
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10586)
at NgModuleRef_.get (core.js:11807)
at resolveNgModuleDep (core.js:10586)

home.module.ts

import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { homeRouting } from './home.routing';
import { HomeComponent } from './home.component';
import { OAuthService } from 'angular-oauth2-oidc';

@NgModule({
  imports: [
    CommonModule,
    homeRouting,
    FormsModule,
    HttpClientModule,
  ],
  providers: [OAuthService],
  declarations: [HomeComponent]
})

export class HomeModule {
}

home.component.ts

import { Component, OnInit } from '@angular/core';
import { OAuthService } from 'angular-oauth2-oidc';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

  private async ConfigureAuth(): Promise<void> {
  }

  constructor(private oauthService: OAuthService) { }

  async ngOnInit() {
    await this.ConfigureAuth();
  }

}

Most helpful comment

You have to import the module

imports: [
    ...
    OAuthModule.forRoot(),
    ...
  ]

All 4 comments

Hello, I'm having the same exact issue. Did anyone manage to fix this? Thanks.

You have to import the module

imports: [
    ...
    OAuthModule.forRoot(),
    ...
  ]

Hey sorry of the delay, yeah that was the issue !
I was watching this https://www.youtube.com/watch?v=RSqREkxe2z0&t=520s they guys did added oAuthModule in providers and it seem to work for him!

You have to import the module

imports: [
    ...
    OAuthModule.forRoot(),
    ...
  ]

This worked for me, thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

godhar picture godhar  路  3Comments

PaulienVa picture PaulienVa  路  4Comments

uzzafar picture uzzafar  路  4Comments

bitbaggi picture bitbaggi  路  3Comments

kneefer picture kneefer  路  3Comments