Open joseluistorres opened 10 years ago
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 notifications@github.com 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:
@service.reconnect 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!
— Reply to this email directly or view it on GitHub.
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 :blush:
Not because I am lazy, but I would say its not really part of quickeebooks.
What I do is this: 1) When a new token is created in my system I store the expiration date along with the "reminder" date (30 days prior to expiration). 2) I have a monthly scheduled task that runs and checks for any tokens with a reminder date of now - if found, automatically renew them. 3) If renewal was successful, update all the attributes, update the new expiration & reminder dates and off we go again.
On Feb 26, 2014, at 11:14 AM, JoseLuis Torres notifications@github.com 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
— Reply to this email directly or view it on GitHub.
Nice, yes, I was wondering, ok thanks for your feedback @ruckus :+1:
@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:
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {
:site => "https://oauth.intuit.com",
:request_token_path => "/oauth/v1/get_request_token",
:authorize_path => "/oauth/v1/get_access_token",
:access_token_path => "/oauth/v1/get_access_token"
})
service.access_token = OAuth::AccessToken.new(consumer, access_token, access_secret)
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 notifications@github.com wrote:
Thanks a lot, it took some time for me to find out how to fill service.access_token,but this seem to work:
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, { :site => "https://oauth.intuit.com", :request_token_path => "/oauth/v1/get_request_token", :authorize_path => "/oauth/v1/get_access_token", :access_token_path => "/oauth/v1/get_access_token" }) service.access_token = OAuth::AccessToken.new(consumer, access_token, access_secret) Its the kind of things that most tutorials and readme's tend to ignore...
— Reply to this email directly or view it on GitHub.
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 toolbag@gmail.com wrote:
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 notifications@github.com wrote:
Thanks a lot, it took some time for me to find out how to fill service.access_token,but this seem to work:
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, { :site => "https://oauth.intuit.com", :request_token_path => "/oauth/v1/get_request_token", :authorize_path => "/oauth/v1/get_access_token", :access_token_path => "/oauth/v1/get_access_token" }) service.access_token = OAuth::AccessToken.new(consumer, access_token, access_secret) Its the kind of things that most tutorials and readme's tend to ignore...
— Reply to this email directly or view it on GitHub.
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!