Javascript 通过dashbord脚本js调用python方法
我有python脚本,可以通过服务帐户获取google api for python的访问令牌,我的项目是php web app 我遵循本教程[嵌入Api] 我已经用json键将脚本放在我的项目中,我做了所有必要的更改,这是我的python脚本Javascript 通过dashbord脚本js调用python方法,javascript,php,python,google-analytics,Javascript,Php,Python,Google Analytics,我有python脚本,可以通过服务帐户获取google api for python的访问令牌,我的项目是php web app 我遵循本教程[嵌入Api] 我已经用json键将脚本放在我的项目中,我做了所有必要的更改,这是我的python脚本 # service-account.py from oauth2client.service_account import ServiceAccountCredentials # The scope for the OAuth2 request. SC
# service-account.py
from oauth2client.service_account import ServiceAccountCredentials
# The scope for the OAuth2 request.
SCOPE = 'https://www.googleapis.com/auth/analytics.readonly'
# The location of the key file with the key data.
KEY_FILEPATH = 'home/mousa/json-key.json'
# Defines a method to get an access token from the ServiceAccount object.
def get_access_token():
print ServiceAccountCredentials.json-key.json(KEY_FILEPATH, SCOPE).get_access_token().access_token
下面是我想调用get\u access\u token()方法的js:
如何调用方法并确保输出为access token???这应该可以帮助您:谢谢,希望
t工作正常,我会试试
gapi.analytics.auth.authorize({
'serverAuth': {
'access_token': '{{"invoke get_access_token()!!?"}'
}
});