简体   繁体   English

Google Oauth2 API-Omniauth Rails

[英]Google Oauth2 api - Omniauth Rails

Currently I'm recovering the omniauth information perfectly fine using the typical setup for omniauth gems. 目前,我正在使用omniauth gem的典型设置来完美地恢复omniauth信息。

I'm retrieving the access_token as a string and storing it into an Authorization model that is associated to a main Users model. 我正在以字符串形式检索access_token并将其存储到与主Users模型关联的Authorization模型中。

So, getting to my problem. 所以,解决我的问题。

I need to access the calenders api and in the docs I see many references like this... 我需要访问calenders api,并且在文档中我看到了很多像这样的引用...

https://www.googleapis.com/calendar/v3//users/me/calendarList/calendarId

This seems fairly intuitive. 这似乎很直观。 I want to access this in conjunction with the access token that I have retrieved. 我想与检索到的访问令牌一起访问此文件。 Something along the lines of this... 与此类似...

https://www.googleapis.com/calendar/v3//users/me/calendarList/calendarId?access_token=blah

so that I can load it directly and more streamlined into Backbone models. 这样我就可以直接加载它,并将其简化为Backbone模型。 However, I don't see anything in the docs and when I try the implementation, it consistently throws me 404s of "Not found" (which is rather annoying and undescriptive. I'd prefer if it threw 422s but I suppose that's a discussion for somewhere else.) 但是,我在文档中什么都没有看到,当我尝试实现时,它始终向我抛出404的“未找到”(这很烦人且不具描述性。我希望它抛出422,但是我想这是一个讨论对于其他地方。)

Is there anything in the docs that provide an example implementation of how to access the info with a token? 文档中是否有任何内容提供了如何使用令牌访问信息的示例实现?

thanks 谢谢

I did a bit more research and found out about the google ruby client gem that was released. 我做了一些进一步的研究,发现了有关已发布的Google ruby​​客户端gem。 Basically, we have to feed the token into the Google::Client instance and pump out an object that has a defined set of methods that can be used on it. 基本上,我们必须将令牌输入到Google :: Client实例中,并抽出一个对象,该对象具有可以在其上使用的一组定义的方法。

I created a special case controller to handle this logic to render out a suitable api. 我创建了一个特例控制器来处理此逻辑,以渲染出合适的api。

TO-DO: Will get into specifics in a bit. 待办事项:稍后会详细介绍。 Currently I'm very tired. 目前我很累。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM