Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientCredentialsTokenHandler doesn't work with Apigee due to use of token_type for auth scheme #1413

Open
rhyscooper opened this issue Sep 20, 2024 · 2 comments

Comments

@rhyscooper
Copy link

Which version of Duende.AccessTokenManagement are you using?
Duende.AccessTokenManagement 3.0.0

Which version of .NET are you using?
net8.0

The ClientCredentialsTokenHandler from Duende.AccessTokenManagement doesn't work with Apigee's oauth 2.0 bearer token implementation due to the token_type being returned being "BearerToken" instead of "Bearer". "BearerToken" is invalid for use as an auth header scheme, therefore all api requests fail with 401. It's clear that Apigee is non-compliant (https://docs.apigee.com/api-platform/reference/policies/oauthv2-policy#non-rfc-compliant-behavior), however as we are consuming someone else's API, we don't control this.

This is similar to the closed issue reported DuendeSoftware/Duende.AccessTokenManagement#38, however that is purely related to case sensitivity of token_type rather than an entirely different token_type being returned from the token api.

It would be useful to be able to override the scheme in the ClientCredentialsClient config and use that instead of the value returned as the token_type.

@leastprivilege
Copy link
Member

Where in the code do you see BearerToken added to the header?

@rhyscooper
Copy link
Author

rhyscooper commented Sep 20, 2024

Unfortunately "BearerToken" is returned as the "token_type" from Apigee oauth api

https://docs.apigee.com/api-platform/reference/policies/oauthv2-policy#non-rfc-compliant-behavior

The token_type returned in the response is used as the scheme in the SetTokenAsync method
https://github.com/DuendeSoftware/Duende.AccessTokenManagement/blob/b0f2ac089375cecaf7c2f3f83bb52af6ded0e54a/src/Duende.AccessTokenManagement/AccessTokenHandler.cs#L85

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

No branches or pull requests

2 participants