You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I've investigated codebase of the gem and seems there is not mechanism for auto refreshing access token when it gets expired. I use the hubspot client in many services and it becomes a little annoying to copy paste code with handing exceptions. Here is a basic example of how it works:
def call
client = ::Hubspot::Client.new(access_token: integration.access_token)
client.crm.contacts.basic_api.get_by_id(contact_id:)
...
rescue Hubspot::Crm::Contacts::ApiError => e
if expired?(e)
Integration::HubspotIntegration::RefreshAccessToken.call(integration:)
retry
end
end
def expired?(error)
JSON.parse(error.response_body)['category'] == 'EXPIRED_AUTHENTICATION'
end
So what would be nice to have:
Automatically refresh access token once it gets expired.
Retry request one more time with fresh access token.
Be able to pass lambda or proc into constructor that will be called with refreshed token.
Hi @vvitto. We discussed this with the team and came to the conclusion that this is not a bad idea. We will try to implement it after we resolve our current issues.
Hi. I've investigated codebase of the gem and seems there is not mechanism for auto refreshing access token when it gets expired. I use the hubspot client in many services and it becomes a little annoying to copy paste code with handing exceptions. Here is a basic example of how it works:
So what would be nice to have:
Example:
I can add this feature by myself if you don't mind and can guide me a little bit, or maybe you know some other ways how to solve my problem?
The text was updated successfully, but these errors were encountered: