我在Python GAE應用程序中理解和實現Google Directory API的用戶觀看功能和推送通知系統(https://developers.google.com/admin-sdk/reports/v1/guides/push#creating-notification-channels)時遇到了一些麻煩。我試圖實現的是,使用我的應用的任何用戶(管理員)都能夠在自己的域中觀看用戶更改。使用Python實現Google Directory API用戶觀看
我已經驗證了我要使用的通知域並執行如下表要求:
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)
現在,接收部分是什麼,我不明白。當我在我的域中添加用戶並檢查應用程序的請求日誌時,我看到一些活動,但沒有可用的數據。我應該如何處理這部分?
任何幫助,將不勝感激。謝謝。
認爲你誤解了我的第一篇文章。我知道我的代碼設置了通知頻道。該設置似乎是成功的。之後我無法解釋數據。應用程序的日誌顯示每次在我的測試域中更改內容(添加新用戶)時都會發生某些情況,但我似乎沒有收到任何相關數據,即使我在應用程序中「偵聽」POST請求也是如此,我從來沒有得到任何回報。 – rok
您每次收到POST請求時都重新建立通知通道似乎並不奇怪?或者你不檢查任何數據的請求主體? – Nick