在我的Glassware中使用其他Google API(共享给g +帐户) [英] Using additional Google APIs in my Glassware (Sharing to g+ accounts)

查看:107
本文介绍了在我的Glassware中使用其他Google API(共享给g +帐户)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python和 Python Mirror API快速入门代码.

I'm trying to share a card ( the html inside it ) from my Glassware using python and the Python Mirror API Quickstart code.

creds = StorageByKeyName(Credentials, '#####', 'credentials').get()
        plus_service = util.create_service('plus', 'v1', creds)

        moment = {"type":"http://schemas.google.com/AddActivity",
        "target": {
        "id": "target-id-1",
        "type":"http://schemas.google.com/AddActivity",
        "name": "The Google+ Platform",
        "description": "A page that describes just how awesome Google+ is!",
        "image": "https://developers.google.com/+/plugins/snippet/examples/thing.png"
                }
        }
        google_request = plus_service.moments().insert(userId='me', collection='vault', body=moment)
        result = google_request.execute()

我得到了这个回复:

HttpError: <HttpError 403 when requesting https://www.googleapis.com/plus/v1/people/me/moments/vault?alt=json returned "Insufficient Permission">

我可以理解这是一个权限问题,但我的问题是,向眼镜用户询问G +权限的建议UI是什么?

I can understand that is a permission problem but my question is, what is the suggested UI to ask to a glass user for G+ permissions?

此外,通过添加" https://www.googleapis.com/auth/plus.login "在请求的权限中,我得到了: https://www.googleapis.com/plus/v1/people/me/moments/vault?alt=json返回了未经授权>

Furthermore, by adding "https://www.googleapis.com/auth/plus.login" in the requested permissions I got this: https://www.googleapis.com/plus/v1/people/me/moments/vault?alt=json returned "Unauthorized">

预先感谢

推荐答案

要获得G +访问权限,您可以使用Mirror API使用的授权过程.对 Mirror API Python快速入门项目进行以下修改:

To get G+ access, you can piggyback on the authorization process that Mirror API uses. Make the following modifications to the Mirror API Python Quickstart project:

首先,为您的项目在 Google API控制台中启用Google+ API.

First, enable the Google+ API in the Google API Console for your project.

其次,在 oauth/hander中. py ,将您的G +范围添加到SCOPES列表中:

Second, in oauth/hander.py, add your G+ scope to the SCOPES list:

SCOPES = ('https://www.googleapis.com/auth/glass.timeline '
          'https://www.googleapis.com/auth/glass.location '
          'https://www.googleapis.com/auth/userinfo.profile '
          'https://www.googleapis.com/auth/plus.login')

第三,撤销旧的身份验证令牌并获取新的身份验证令牌.通过退出并重新登录Quickstart实例的Web前端来执行此操作.登录时,登录页面应更新以列出新的Google+权限:

Third, revoke your old auth tokens and get fresh ones. Do this by signing out of and signing back into your Quickstart instance's web front end. When you sign in, the sign in page should be updated to list the new Google+ permission:

通过这些步骤,您发布的代码应该可以使用.注释一下是否可以,我可以帮助您继续调试.

With these steps, the code you posted should work. Comment if it doesn't and I can help you continue debugging.

这篇关于在我的Glassware中使用其他Google API(共享给g +帐户)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆