【问题标题】:For django-storages and GCE, how do you set the GS_CREDENTIALS?对于 django-storages 和 GCE,如何设置 GS_CREDENTIALS?
【发布时间】:2018-05-21 18:32:51
【问题描述】:

对于 django-storages 和 google 计算引擎 (GCE),您如何为 Web 应用程序创建和设置凭据?

这是当前文档:http://django-storages.readthedocs.io/en/latest/backends/gcloud.html

【问题讨论】:

    标签: django google-cloud-storage google-compute-engine


    【解决方案1】:

    为了节省其他人的时间,我将 driesdesmetsww314manufont 添加到 2 个单独的 github 问题中的答案重新发布

    第 1 步 (driesdesmet)

    pip install google-cloud-storage

    第 2 步 (sww314)

    在此处执行步骤 1、2 和可选的 4(不是步骤 3):

    https://github.com/jschneier/django-storages/issues/455#issuecomment-360288072

    第 3 步。 (manufont)

    代替:

    GS_CREDENTIALS = "path/to/credentials.json"
    

    这样做:

    from google.oauth2 import service_account
    
    GS_CREDENTIALS = service_account.Credentials.from_service_account_file(
        "path/to/credentials.json"
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-18
      • 1970-01-01
      • 1970-01-01
      • 2012-09-12
      • 2013-09-03
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      相关资源
      最近更新 更多