views.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:wagalytics 作者: tomdyson 项目源码 文件源码
def get_access_token(ga_key_filepath):
    # from https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/
    # Defines a method to get an access token from the credentials object.
    # The access token is automatically refreshed if it has expired.

    # The scope for the OAuth2 request.
    SCOPE = 'https://www.googleapis.com/auth/analytics.readonly'

    # Construct a credentials objects from the key data and OAuth2 scope.
    _credentials = ServiceAccountCredentials.from_json_keyfile_name(
        ga_key_filepath, SCOPE)

    return _credentials.get_access_token().access_token
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号