I want to get contact from Google Plus. I am using
我想从谷歌+取得联系。我用
gem "omniauth"
gem "omniauth-google-oauth2"
for authentication and
为验证和
gem "google-api-client"
for comunicate with google apis.
用于与谷歌api协同。
So far authentication is working fine and I got access_token after authentication. Now problem is I couldn't find a way to get list of people in my circle (My Google Plus Contact).
到目前为止,身份验证运行良好,我在身份验证之后获得了access_token。现在的问题是我找不到一种方法来得到我圈子里的人的名单(我的谷歌+联系人)。
Is there any way to do this.
有什么办法吗?
Specifically I need to know is there any gem more like "fb_graph" for google?
具体地说,我需要知道谷歌是否有更像“fb_graph”的gem ?
I found this trick
我发现这个技巧
https://plus.google.com/u/0/_/socialgraph/lookup/visible/o=%5Bnull%2Cnull%2C%22_UID_%22%5D&rt=j
Just need to put "UID" and you can get contacts in your circle but their name and ID only. But I need more information...
只需要输入“UID”,你就可以在你的圈子里找到联系人,但只能找到他们的名字和ID。但我需要更多的信息……
WorkFlow
工作流
client = Google::APIClient.new
client.authorization.client_id = GOOGLE_CONFIG[:app_id]
client.authorization.client_secret = GOOGLE_CONFIG[:app_secret]
client.authorization.access_token = token
plus = client.discovered_api('plus')
data = client.execute( plus.people.list, :collection => 'connected', :userId => 'me').data
In data I get this message
在数据中,我得到了这个信息。
<Google::APIClient::Schema::Plus::V1::PeopleFeed:0x6569248 DATA:{"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"insufficientPermissions", "message"=>"Insufficient Permission"}], "code"=>403, "message"=>"Insufficient Permission"}}>
I found similar problem here but solution is still needs to be find out.
我在这里也遇到了类似的问题,但解决的办法还有待进一步研究。
1 个解决方案
#1
3
I need to add Scope in devise initializers and then by auth token everything seems to be working perfectly.
我需要在设计初始化器中添加范围,然后根据auth标记,一切似乎都运行得很好。
scope: "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
OR Add this line
或添加这一行
config.omniauth :google_oauth2, GOOGLE_CONFIG[:app_id], GOOGLE_CONFIG[:app_secret],{ access_type: "offline", approval_prompt: "force", scope: 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile', name: 'google'}
#1
3
I need to add Scope in devise initializers and then by auth token everything seems to be working perfectly.
我需要在设计初始化器中添加范围,然后根据auth标记,一切似乎都运行得很好。
scope: "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
OR Add this line
或添加这一行
config.omniauth :google_oauth2, GOOGLE_CONFIG[:app_id], GOOGLE_CONFIG[:app_secret],{ access_type: "offline", approval_prompt: "force", scope: 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile', name: 'google'}