Skip to content

Is it possible to access request metadata in CallCredentials #2661

@jakoss

Description

@jakoss

My use case is that i want to perform custom logic inside my CallCredentials implementation based on the metadata set manually during request creation.

So when i execute my gRPC call like this:

var response = await someService.ExecuteSomeMethod(new RequestClass(), headers: new Metadata
        {
            { "CustomData", "some data" }
        });

I would like to access the "CustomData" inside the CallCredentials, like this:

internal static async Task InterceptAuthentication(AuthInterceptorContext _, Metadata metadata, IServiceProvider provider)
    {
        var myCustomData = metadata["CustomData"];
    }

So far, the passed metadata is just empty and the documentation suggests that this is only for appending additional data. Right now i need to use very hacky AsyncLoca-based workaround for that. Is there a way to access the original metadata for the request here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions