一天尝试,测试,谷歌搜索...我寻求一些帮助我尝试使用Omniauth和Google日历。Omniauth的工作就像魅力一样,但我只是无法将其链接到Google API
我想我几乎阅读了所有内容,但我仍然收到此错误消息:
dailylimitexceededunreg:超过未经身份验证的每日限制。 继续使用需要注册。
这意味着我的呼叫无法正确地"连接"到我的auth,这似乎是有效的。我的令牌在数据库中,但是我想登录/识别/呼叫,并有其他错误消息。
client_id = google :: auth :: clientid.from_file('..... googleusercontent.com.json')
scopes = ['userinfo.email,calendar']
token_store = Google::Auth::MyTokenStore.new()
authorizer = Google::Auth::WebUserAuthorizer.new(
client_id,
scopes,
token_store,
'http://localhost:3000'
)
# credentials = Google::Auth::UserAuthorizer.new( . # Anotheir test
# client_id,
# scopes,
# token_store,
# 'http://localhost:3000'
# )
#
# authorizer = credentials.get_credentials_from_code(
# GoogleUser.find(session[:user_id]) # I tested token ... notking worked
# )
calendar = Google::Apis::CalendarV3::CalendarService.new
calendar.authorization = authorizer
calendar_id = 'primary'
@result = calendar.list_events(calendar_id,
max_results: 10,
single_events: true,
order_by: 'startTime',
time_min: Time.now.iso8601)
和我的令牌存储,我不明白为什么,但从未打电话
class MyTokenStore
class << self
attr_accessor :default
end
def load(_id)
puts "********** load ************"
return GoogleUser.find(session[:user_id]).access_token
end
def store(_id, _token)
puts "********** store ************"
@user.access_token = _token
end
def delete(_id)
puts "********** delete ************"
@user.access_token = nil
end
end
结束结束
对于未来的读者:我采用了另一种技术,在这里阅读了一篇出色的文章:http://gmile.me/simple-google-auth/我跟随它并使用签名,它像魅力一样工作