为GOOGLE_APPLICATION_CREDENTIALS设置凭据的替代方法

我有一个使用 Google Vision API </ em>和 Google的Go应用 视频智能</ em> API。
要输入我的凭据,请设置名为 GOOGLE_APPLICATION_CREDENTIALS </ code>的环境变量。 为此,我为此变量分配了一个文件路径,该文件路径指向我的凭据存储在其中的目录。</ p>

问题:</ em> </ p>

我的凭据最初不是 </ em>保存在文件中。 而是将它们分配给我的应用程序内的字符串变量。
作为一种解决方法,我将该值存储到一个临时文件中,然后将其路径分配给 GOOGLE_APPLICATION_CREDENTIALS </ code>,如上所述。</ p>

问题:</ em> </ p>

是否可以为 cloud.google.com/go/vision/apiv1 </ code设置API凭据 >没有此文件?</ p>
</ div>

展开原文

原文

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个回答



我不知道它如何在Google Vision Api上使用,但对于Google Sheets Api则有这样的东西:</ p>

  config,错误:= google.ConfigFromJSON(b,“ https://www.googleapis.com/auth/spreadsheets.readonly”)
</ code> </ pre>
\ n

所以b是从文件 credentials.json </ code>中获取的一个切片,您可以自己从其他任何地方获取它</ p>
</ div>

展开原文

原文

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐