Skip to content

calling authenticate fails to retrieve fresh token if token is expired for IAMAuthenticator #44

@kcculhwch

Description

@kcculhwch

https://github.com/IBM/ruby-sdk-core/blob/9f94b77921daa2212f0d38efba1b3ca91dfc6e28/lib/ibm_cloud_sdk_core/authenticators/iam_authenticator.rb#L39C59-L39C71

It looks like the problem is in this section here: but it could be resolved in other places

    def authenticate(headers)
      headers["Authorization"] = "Bearer #{@token_manager.access_token}"
    end

Instead of @token_manager.access_token it could simply call @token_manager.token falling back on the JWT manager's code to check the expiration time of the token and get a new one if required.

For now, I have monkey patched the class to make an attr_acessor for the token manager from the authenticator so that I can call token manually before using the authenticator

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