Skip to content

How to customize headers (async) on a per endpoint basis? #4290

Closed

Description

I am working on implementing security for my web application with AWS Cognito. I've written a little Auth API that will return an access token for a given scope, and I would like to customize my endpoints so that they automatically add the Authorization header to the request with an appropriately scoped access token.

So, for instance, my endpoint for reading the schedule would need an access token with the scope "schedules.read".

Since I may need to asynchronously fetch the accessToken if a valid one for that scope isn't cached, I can't use the headers property on the endpoint.

There is the prepareHeaders function on the baseQuery which looks promising. However, I'd need a good way to inform that function of what scopes to request for the endpoint in question. Is there mechanism to add and retrieve metadata for endpoints that could be used in prepareHeaders? Or a way to use an asynchronous function on the endpoint definition to set the headers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions