angular-oauth2-oidc angular 17 standalone

Discussão em 'Angular' iniciado por pufo, Abril 6, 2025.

  1. pufo

    pufo Guest

    I am using angular 17 standalone. I installed the angular-oauth2-oidc library. It turns out that he doesn't get the token. I have the same angular application in an older version with NgModule and it works fine. Do you know a way to solve the problem? It is also possible to change the library to one that will work with Angular Standalone

    export class AppComponent implements OnInit {
    constructor(private oauthService: OAuthService) {
    this.configureOAuth();
    }
    private configureOAuth(): void {
    const authConfig: AuthConfig = {
    issuer: 'url',
    redirectUri: window.location.origin,
    responseType: 'code',
    requireHttps: false,
    clientId: 'm0063',
    scope: 'openid profile email offline_access roles',
    };
    this.oauthService.configure(authConfig);
    //this.oauthService.loadDiscoveryDocumentAndLogin();
    }
    ngOnInit(): void {}

    login() {
    this.oauthService.loadDiscoveryDocumentAndLogin().then(x => {
    setTimeout(() => {
    this.oauthService.initCodeFlow();
    });
    });
    }

    logout() {
    this.oauthService.logOut({ customParameters: true, client_id: 'm0063' });
    }
    }

    export const appConfig: ApplicationConfig = {
    providers: [
    provideAnimations(),
    provideHttpClient(),
    provideRouter(
    appRoutes,
    withPreloading(PreloadAllModules),
    withInMemoryScrolling({ scrollPositionRestoration: 'enabled' }),
    withViewTransitions()
    ),
    importProvidersFrom(HttpClientModule),
    provideOAuthClient( {
    resourceServer: {
    allowedUrls: ['localhost:4200', 'url:8080'],
    sendAccessToken: true
    }
    }
    ),
    provideUrl(),
    }


    error:your text Unchecked runtime.lastError: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

    I trying do new module and implement config as in For.root in ngModule, but it is not working still.

    Continue reading...

Compartilhe esta Página