我試圖將雲端點合併到我的應用程序中,目前我正在使用Python Quickstart來進行概念驗證。當我嘗試調用一種方法將卡片發送到我的眼鏡時,我遇到了問題。以下是我的代碼,請忽略缺少的縮進。雲端點 - Google Glass對象沒有屬性'mirror_service'
@endpoints.api(name='tasks', version='v1',
description='API for TaskAlert Management',
allowed_client_ids=[CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID])
class TaskAlertApi(remote.Service):
@endpoints.method(Task, Task,
name='task.insert',
path='tasker',
http_method='POST')
def insert_task(self, request):
TaskModel(author=request.author, content=request.content, date=request.date).put()
themirror = MainHandler()
themirror._insert_map_with_distance_from_home()
return request
所以,當 「themirror._insert_map_with_distance_from_home()」 被稱爲我收到以下錯誤。有沒有人有什麼建議?我正嘗試從myappspot.com/_ah/api/explorer調用此方法。
in _insert_map_with_distance_from_home
self.mirror_service.timeline().insert(body=body).execute()
AttributeError: 'MainHandler' object has no attribute 'mirror_service'
謝謝你的指導。我正在通過它,也從http://stackoverflow.com/questions/18213622/using-additional-google-apis-in-my-glassware-sharing-to-g-accounts整合評論這裏是錯誤我'目前正在獲取。遇到來自ProtoRPC方法實現的意外錯誤:HttpError(當請求https://www.googleapis.com/mirror/v1/timeline?alt=json返回「Insufficient Permission」時,<)任何想法? –
marty331
當您對API的請求進行身份驗證(我假設您仍在使用API Explorer進行測試?)時,您是否已將「https:// www.googleapis.com/auth/glass.timeline」添加爲其他範圍?因爲否則,您無權使用獲取的訪問令牌寫入時間表。 – Scarygami
Scarygami,那正是我錯過的!我現在已經連接了端點,並且能夠將時間線卡發送給Glass!我無法感謝你的幫助! – marty331