question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetAccessTokenForRequestAsync response token missing kid in header

See original GitHub issue

I have been converting code from Java version to .NET version.

Issue we ran into is that when we get a bearer token for API calls, the .NET version is missing the “kid” field in the header of the JWT token. Otherwise token is valid.

.NET :

_credentials = ServiceAccountCredential.FromServiceAccountData(File.OpenRead(serviceAccountFile));
_token = _credentials.GetAccessTokenForRequestAsync(_audience).Result;

Java :

ServiceAccountJwtAccessCredentials credentials = null;
credentials = ServiceAccountJwtAccessCredentials.fromStream( new FileInputStream( accountFile ),
        new URI( audience ) );
String token = credentials.getRequestMetadata( ).get( HttpHeaders.AUTHORIZATION )
        .get( 0 );

Tokens are otherwise identical and correct. However, the missing kid field is causing error. Both audience and account file are the same.

Are we doing something wrong here, is there a bug in the GetAccessTokenForRequestAsync function?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Mansikkacommented, Jul 2, 2020

Hi, I am happy to report that everything works. Thank you @amanda-tarafa for your help!

1reaction
Mansikkacommented, Jul 1, 2020

Thanks! I will report back tomorrow if there is an issue after I have updated everything and ran the tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JWT token missing part of header on .NET, but not in Java
NET the token we receive for authentication is missing part of the header ... NET token is missing "kid" part. .NET token header...
Read more >
Access token suddenly stopped containing the `kid` header
Today the access token stopped containing the kid header which means that we can no longer decode it. We've not made any changes...
Read more >
Access token header 'kid' missing - Troubleshooting
I'am generating an access token, when I decode the JWT, I get only the stuff below without the “kid” to be able to...
Read more >
KID in id_token header not matching kid in metadata
When I request a token and ID token the kid claim in the header does not match the key ids in the /keys...
Read more >
Performance tips | Generic pass
In order to receive a gzip-encoded response you must do two things: Set an Accept-Encoding header, and modify your user agent to contain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found