2
我試圖從谷歌獲得oauth,每次我需要複製並粘貼我的控制檯中生成的代碼後進行身份驗證! 我想讓它自動化嗎? 任何想法我怎麼能做到這一點?試圖從Google DFA報表工具中獲取數據?
我有這段代碼!
DFA_USER_PROFILE_NAME='MYPROFILE_NAME'
scope = ["https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/dfareporting"]
try:
redirect_uri=redirect_uri='urn:ietf:wg:oauth:2.0:oob'
flow=flow_from_clientsecrets('Location of the json file', scope, redirect_uri, message)
authorize_url = flow.step1_get_authorize_url()
self.redirect(authorize_url)
credential = flow.step2_exchange(self.request.params)
storage=StorageByKeyName(credentials,user.user_id(),'credentials'
)
storage.put(credentials)
user=user.get_current_user()
credentials = client.oauth2credentials
client.oauth2credentials = credentials
http = httplib2.Http()
except BaseException as e: print "this is really a error that has occured ",e
我想,但我不知道我要去的地方錯了嗎?
什麼是self.params? Google Cloud中免費提供此服務嗎?
我們有** PUT方法**我們如何使用代碼在這裏? 存儲證書並使用** GET **方法。 如何創建.dat文件?在這種情況下 ? – rshvkmr
.dat文件在第一次運行時自動爲您創建。隨意忽略最後兩行,只需使用http對象,它應該適用於GET和PUT請求。 – aeijdenberg