Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过dashbord脚本js调用python方法_Javascript_Php_Python_Google Analytics - Fatal编程技术网

Javascript 通过dashbord脚本js调用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

我有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.
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()!!?"}'
  }
});