dsfgds4215 2018-10-22 08:45
浏览 1382

为GOOGLE_APPLICATION_CREDENTIALS设置凭据的替代方法

I've a Go app that uses the Google Vision API and Google Video intelligence API. To enter my credentials, I set the environment variable called GOOGLE_APPLICATION_CREDENTIALS. To do so, I assign a file path to this variable that points to the directory where my credentials are stored in.

Problem:

My credentials are not initially saved in a file. Instead they are assigned to a string variable inside my app. As a workaround, I store that value to a temporary file and then assign it's path to GOOGLE_APPLICATION_CREDENTIALS, like described above.

Question:

Is it possible to set API credentials for cloud.google.com/go/vision/apiv1 without this file?

  • 写回答

1条回答

  • dongsu3664 2018-10-22 09:19
    关注

    i do not know how it on Google Vision Api, but for the Google Sheets Api there is such stuff:

    config, err := google.ConfigFromJSON(b, "https://www.googleapis.com/auth/spreadsheets.readonly")
    

    so b is a slice taken from the file credentials.json u can just take it from any other place by yourself

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?