Skip to content

HTTP Interceptor: Attach token optionally #114

@felixfiskare

Description

@felixfiskare

Describe the problem you'd like to have solved

Currently I can only decide if I always or never want a token to be attached to a request. I'm not aware of a way to have a token attached to a request if the user is authenticated and to send the request without a token if the user is not authenticated.
This is a problem for Endpoints which serve content to authenticated and un-authenticated users.

Describe the ideal solution

The ideal solution would be for the interceptor to wait till initial authentication procedure is finished and then continue dispatching requests with a token or without.

Alternatives and current work-arounds

My current workaround is a interceptor which calls getAccesssTokenSilently() and adds a token upon success or no token upon error but dispatches the request in both cases. This is not ideal (because I can't just observe the accesstoken), but it works.

Additional context

Other people seem to have the same usecase as me: https://community.auth0.com/t/auth0-angular-http-interceptor-error-when-user-is-not-logged-in/50866/3

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA feature has been asked for or suggested by the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions