0
我可以使用下面提到的代碼將事件成功推送到Google日曆中。每次嘗試推送事件時,下面的控制器代碼都會刷新令牌。它工作正常。使用刷新令牌生成訪問令牌的查詢
class Add2gcalendarController < ApplicationController
before_filter :authenticate_user!
def push
event = {'summary' => 'Appointment','location' => 'Somewhere','start' => {'dateTime' => '2014-06-03T10:00:00.000-07:00'},'end' => {'dateTime' => '2014-06-03T10:25:00.000-07:00'}}
client = Google::APIClient.new
client.authorization.client_id =ENV["GOOGLE_KEY"]
client.authorization.client_secret = ENV["GOOGLE_SECRET"]
client.authorization.grant_type = 'refresh_token'
client.authorization.refresh_token = saved_refresh_token
client.authorization.fetch_access_token!
service = client.discovered_api('calendar', 'v3')
@result = client.execute(
:api_method => service.events.insert,
:parameters => {'calendarId' => 'primary'},
:body => JSON.dump(event), # where cal is the object containing at least "summary".
:headers => {'Content-Type' => 'application/json'})
end
我的問題:
它是一個很好的做法,刷新令牌的每次我試圖推動的事件,不論令牌是否得到了過期或不?
使用刷新令牌生成訪問令牌有限制嗎?
沒有面對任何5xx錯誤,我以前推事件的方式。可能是我沒有做大規模:)考慮到這是一個不好的做法,我沒有修改我的代碼,以適應只有在需要時刷新。謝謝。 – nk06