ManagementApiClient and other clients' constructors should accept Func<Task<string>> getToken
or Func<ValueTask<string>> getToken
#759
Labels
feature request
A feature has been asked for or suggested by the community
Checklist
Describe the problem you'd like to have solved
Currently the constructor of
ManagementApiClient
requires atoken
. However, tokens are expirable. To avoid401 Unauthorized
errors the calling code should ensure token is still valid or recreate the instance ofManagementApiClient
if token has expired.IMO, this is an accidental complexity.
Describe the ideal solution
If I could provide a callback for acquiring a new token, things could be simplified as verifications become the responsibility of
ManagementApiClient
and clients it exposes (Organizations, Users, etc.)Alternatives and current workarounds
As a workaround I pass an http client with a delegating handler which refreshes (if needed) the token and sets authorization header as
Bearer <token>
:Code of the handler:
Additional context
No response
The text was updated successfully, but these errors were encountered: