How to add access token go geneated openapi typescript-angular client

Discussão em 'Angular' iniciado por Moritz Vogt, Dezembro 23, 2024.

  1. Moritz Vogt

    Moritz Vogt Guest

    I´m having following setup...
    Backend: Spring boot with openapi code generation for my angular client
    Frontend: Angular
    I can import the generated code into my project and I can easily use the methods from the generated code. The Problem is I´m not able to authenticate at the backend. In the README.md of the generated code there is following

    // configuring providers with an authentication service that manages your access tokens
    import { ApiModule, Configuration } from '';

    @NgModule({
    imports: [ ApiModule ],
    declarations: [ AppComponent ],
    providers: [
    {
    provide: Configuration,
    useFactory: (authService: AuthService) => new Configuration(
    {
    accessToken: authService.getAccessToken.bind(authService)
    }
    ),
    deps: [AuthService],
    multi: false
    }
    ],
    bootstrap: [ AppComponent ]
    })
    export class AppModule {}


    How does the AuthService look like or the getAccessToken function of the Service? If I´m trying to build my own Service which gets the token, the application wont work anymore. There is only a white page and no errors displayed.

    How can I implement the token so that it is used by the generated typescript client?

    Continue reading...

Compartilhe esta Página