heroku - 部署我的应用程序时,我应该将我的 client_secret.json 文件存储在哪里?
问题描述
部署应用程序的新手,所以可能是一个愚蠢的问题,但这是我的问题:
我正在使用 Google 的 Youtube Data API 来获取有关用户喜欢的视频的一些信息,因此我必须通过开发者控制台获取凭据。然后系统提示我下载一个包含我的客户端 ID 和客户端密码等的 json 文件,并将其存储在我的根目录中。
这在开发中很好,我可以看到这个文件,但我的问题是部署到 Heroku 需要我将这个文件上传到 Github,据我所知,从而暴露我的客户端密钥。
显然我不能这样做,所以我希望有人可以分享一些关于如何在部署时访问这个文件的智慧?
这是使用我的代码中的文件作为参考的函数:
@app.route('/handle_redirect')
def oauth2callback():
# Specify the state when creating the flow in the callback so that it can
# verified in the authorization server response.
state = session['state']
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
CLIENT_SECRET_FILE, scopes=SCOPES, state=state)
flow.redirect_uri = url_for('oauth2callback', _external=True)
# Use the authorization server's response to fetch the OAuth 2.0 tokens.
authorization_response = request.url
flow.fetch_token(authorization_response=authorization_response)
# Store credentials in the session.
# ACTION ITEM: In a production app, you likely want to save these
# credentials in a persistent database instead.
credentials = flow.credentials
session['credentials'] = credentials_to_dict(credentials)
return redirect(url_for('home'))
CLIENT_SECRET_FILE 位于我的根目录中,但显然在上传到 Github 之前必须将其省略。提前致谢!
解决方案
推荐阅读
- spring - 基于位置的阻止请求
- java - Java中的标记循环
- django - 如何在保存 django 之前将文件转换为 mp3?
- angular - Angular 6 生产构建抛出语法错误
- ios - 以相同的 Alpha 混合金属
- javascript - 使用深层链接的 ng bootstrap 下拉菜单样式
- regex - 一种在大文本文件中提取 IP:端口;数据出现的方法?
- hyperledger-fabric - 如何在结构中设置背书策略
- indexing - 使用 CosmosDB 数据源的 Azure 搜索显示集合中的文档,但搜索资源管理器显示所有 NULL 或 EMPTY 值
- c - 如何连续传输数据?