How to use Google API credentials json on Heroku?

后端 未结 10 1438
深忆病人
深忆病人 2020-12-03 05:36

I\'m making an app using Google Calendar API, and planning to build it on Heroku.
I have a problem about authentication. Usually I use credential json file for that, but

10条回答
  •  时光说笑
    2020-12-03 06:26

    You can create the JSON key file by adding a .profile file to the repo, which will be executed when Heroku starts up the container.

    Set a config variables:

    heroku config:set GOOGLE_APPLICATION_CREDENTIALS=gcp_key.json
    heroku config:set GOOGLE_CREDENTIALS=
    

    The GOOGLE_CREDENTIALS is easier to set in the Heroku dashboard.

    Create a .profile with a line to write the json file:

    echo ${GOOGLE_CREDENTIALS} > /app/gcp_key.json
    

    Obviously, commit the changes to .profile and push to heroku.


    The recommended buildpack doesn't work anymore and, in any case, this feels more direct without being hard.

提交回复
热议问题