Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
+ Don't get a new access token on each request if we already have one.

Version 0.4.0
=========================

Expand Down
17 changes: 16 additions & 1 deletion lib/google_cells/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,28 @@ def request(method, url, params={})
url << '?' unless url[-1] == "?"
url << params[:url_params].to_a.map{|k,v| "#{k}=#{v}"}.join('&')
end
GoogleCells.client.authorization.fetch_access_token!

authorize

GoogleCells.client.execute!(
:http_method => method,
:uri => url,
:headers => params[:headers],
:body => params[:body]
)
end

def authorize
if !auth.access_token || auth.expired?
GoogleCells.client.authorization.fetch_access_token!
end
end

private

def auth
GoogleCells.client.authorization
end

end
end