【发布时间】:2017-05-28 15:04:19
【问题描述】:
我在我的 Python GAE 应用程序中理解和实现 Google Directory API 的用户观看功能和推送通知系统 (https://developers.google.com/admin-sdk/reports/v1/guides/push#creating-notification-channels) 时遇到了一些问题。我想要实现的是,任何使用我的应用程序的用户(管理员)都能够在他自己的域中观察用户的变化。
我已经验证了我想要用于通知的域,并按如下方式实现了监视请求:
directoryauthdecorator = OAuth2Decorator(
approval_prompt='force',
client_id='my_client_id',
client_secret='my_client_secret',
callback_path='/oauth2callback',
scope=['https://www.googleapis.com/auth/admin.directory.user'])
class PushNotifications(webapp.RequestHandler):
@directoryauthdecorator.oauth_required
def get(self):
auth_http = directoryauthdecorator.http()
service = build("admin", "directory_v1", http=auth_http)
uu_id=str(uuid.uuid4())
param={}
param['customer']='my_customer'
param['event']='add'
param['body']={'type':'web_hook','id':uu_id,'address':'https://my-domain.com/pushNotifications'}
watchUsers = service.users().watch(**param).execute()
application = webapp.WSGIApplication(
[
('/pushNotifications',PushNotifications),
(directoryauthdecorator.callback_path, directoryauthdecorator.callback_handler())],
debug=True)
现在,接收部分是我不明白的。当我在我的域中添加用户并检查应用程序的请求日志时,我看到了一些活动,但没有可用的数据。我应该如何处理这部分?
任何帮助将不胜感激。谢谢。
【问题讨论】:
标签: python google-app-engine google-admin-sdk