-
Notifications
You must be signed in to change notification settings - Fork 67
How to validate that the token is not expired #127
Comments
It appears that Intuit doesn't provide a way to check if a token is active or not (based on their docs, the page you linked too, there isn't a "Status Check" endpoint). I guess if you were to make a request with an invalid token you'd get a authorization fault. Its not as clean as having a distinct endpoint, I know. On Feb 26, 2014, at 11:02 AM, JoseLuis Torres [email protected] wrote:
|
That's right, exactly, I got an exception when trying to do any request with an expired token. I was thinking in implementing a fix to track the "connect" date and check it together with .reconnect to avoid the expired token, I don't know if it's a fix for quickeebooks or for our implementation though 😊 |
Not because I am lazy, but I would say its not really part of quickeebooks. What I do is this:
On Feb 26, 2014, at 11:14 AM, JoseLuis Torres [email protected] wrote:
|
Nice, yes, I was wondering, ok thanks for your feedback @ruckus 👍 |
@ruckus: can you share a code for renewing token? |
Sure, I have this method in my class which stores the tokens: def renew_intuit_token!
service =
case flavor
when "QBD"
Quickeebooks::Windows::Service::AccessToken.new
when "QBO"
Quickeebooks::Online::Service::AccessToken.new
end
service.access_token = consumer
service.realm_id = realm_id
response = service.reconnect
if response.error_code.to_i == 0
# ErrorCode=0 is successful
self.access_token = response.token
self.access_secret = response.secret
self.token_expires_at = 6.months.from_now
self.reconnect_token_at = 5.months.from_now
save
else
Rails.logger.info("Intuit Response: #{response.to_xml}")
raise "Failed to renew OAuth Token: #{response.error_message}"
end
end |
Thanks a lot, it took some time for me to find out how to fill service.access_token,but this seem to work:
Its the kind of things that most tutorials and readme's tend to ignore... |
Yes for sure. This is covered in the README at: and https://github.com/ruckus/quickbooks-ruby#creating-an-oauth-access-token On Jul 21, 2014, at 10:26 AM, Yuri Lopukhov [email protected] wrote:
|
Hah, I just realized I sent links for my other QB library and not for quickeebooks. But looking in the Quickeebooks README I have the same lines essentially. On Jul 21, 2014, at 11:02 AM, Cody Caughlan [email protected] wrote:
|
Hi there,
Is there any way to check that the current token of a customer is expired or not, other than doing something like:
I'm trying to find a workaround for this https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0020_connect/0010_from_within_your_app/implement_oauth_in_your_app/token_renewal_and_expiration
Thanks!
The text was updated successfully, but these errors were encountered: