[英]Google api ruby client failing
I'm having trouble using the Google API Client on a ruby project. 我在ruby项目上使用Google API客户端时遇到问题。
I'm following the code example provided by google. 我正在遵循google提供的代码示例。
The README is here . 自述文件在这里 。 The source code you personalize is here .
您个性化的源代码在这里 。
It lays the foundations for a basic sinatra app which redirects you to Google where you can sign in and authorize the app to see your calendar information. 它为基本的sinatra应用程序奠定了基础,该应用程序将您重定向到Google,您可以在其中登录并授权该应用程序查看您的日历信息。
After that it directs you back to your app where I am met with the following error: 之后,它将引导您返回遇到以下错误的应用程序:
undefined method 'bytesize' for #<Faraday::Response:0x007f98f5beb668>
The trace hops from sinatra to thin to rack and back to sinatra - nothing really useful in there. 轨迹从sinatra跳到细线再到机架再回到sinatra-那里没有什么真正有用的。 I know the last code to be called from the app is:
我知道从应用程序调用的最后一个代码是:
result = @client.execute(:api_method => @calendar.events.list, :parameters => {'calendarId' => 'primary'})
I've seen some other stackoverflow posts similar to this but in those cases people are always defining their Faraday parameters themselves. 我见过其他一些与此类似的stackoverflow帖子,但是在那种情况下,人们总是自己定义法拉第参数。 Is this an issue with the Google API or does anyone have any suggestions where I might be doing something wrong?
这是Google API的问题,还是有人对我做错事有任何建议?
Thanks 谢谢
For those hitting the same problem: I have not found a solution. 对于遇到同样问题的人:我没有找到解决方案。 I have however successfully connected an app to the Google API and can access all the info and methods I want.
但是,我已成功将应用程序连接到Google API,并可以访问我想要的所有信息和方法。
Decided to go about this with omniauth
. 决定使用
omniauth
此omniauth
。 It's really simple, there's a railscast episode on how omniauth works, and a great walk through of using omniauth to connect to Google here . 真的很简单,这里有一个关于omniauth的工作原理的专题节目 ,以及在此处使用omniauth连接到Google的完整介绍。 It describes specifically the act of connecting to the Google Calendar, but all you would need to do is change the
client.discovered_api
setter and the client.execute
call in the sessions_controller to which ever you want. 它专门描述了连接到Google日历的操作,但是您所需要做的就是将
client.discovered_api
setter和client.execute
调用更改为所需的名称。 Decent documentation and code examples at developers.google.com/google-apps/calendar/v3/reference/ 位于developer.google.com/google-apps/calendar/v3/reference/上的不错的文档和代码示例
Best of luck. 祝你好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.