Skip to content

bug: IamJwtCredentialsProvider fails because KID is not provided #34

@WizMe-M

Description

@WizMe-M

However yandex cloud docs about getting IAM from JWT token says that KID (key id) field is required to be provided in JWT, IamJwtCredentialsProviderdoesn't require it and creates incorrect JWT token. That behavior leads to such exceptions (see stacktrace below):

Grpc.Core.RpcException: Status(StatusCode="Unauthenticated", Detail="The required field 'kid' is missing from the JWT header")
    at Grpc.Net.Client.Internal.HttpClientCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
    at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
    at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
    at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
    at Yandex.Cloud.Iam.V1.IamTokenService.IamTokenServiceClient.Create(CreateIamTokenRequest request, CallOptions options)
    at Yandex.Cloud.Iam.V1.IamTokenService.IamTokenServiceClient.Create(CreateIamTokenRequest request, Metadata headers, Nullable`1 deadline, CancellationToken cancellationToken)
    at Yandex.Cloud.Credentials.IamJwtCredentialsProvider.GetToken()

The solution is to get KID from ctor parameters and create headers with KID value in it.

Related:
PR with authorized keys credentials provider: #27
Issue with request for authorized keys credentials provider: #29

Metadata

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