AutoML自然语言令牌 [英] AutoML Natural Language Token

查看:72
本文介绍了AutoML自然语言令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是AutoML Natural Language API,它带有经过自定义训练的模型来预测结果.

I'm using AutoML Natural Language API, with my custom trained model to predict results.

为了使用此服务,我通过Cloud Shell生成了一个授权令牌,该令牌启用了api请求.

In order, to use this service, I generate a Authorization token through Cloud Shell, that enables api requests.

因此,我配置/创建了服务帐户,并向该服务帐户添加"automl.editor"规则,并且:

So, I configured/created the service account and add "automl.editor" rule to service account, and:

->导出GOOGLE_APPLICATION_CREDENTIALS =/home/[项目ID]/[json密钥文件]

-> export GOOGLE_APPLICATION_CREDENTIALS=/home/[project id]/[json key file]

-> gcloud auth应用程序-默认打印访问令牌

->gcloud auth application-default print-access-token

它返回有效令牌,该令牌可以使用1小时.

It returns a valid token that works for 1 hour.

有什么办法可以获取更长的有效令牌?(或者我必须生成其他吗?)

Is there any way to get a valid token for longer time? (or do I have to generate other?)

https://automl.googleapis.com/[version]/projects/[项目 ID]/位置/[本地ID]/模型/[模型ID]:预测

https://automl.googleapis.com/[version]/projects/[project id]/locations/[local id]/models/[MODEL ID]:predict

谢谢.

推荐答案

1小时访问令牌的生存时间是固定的,不能更改.一旦过期,您必须通过手动打印或通过刷新令牌来生成新的

The 1 hour access token life time is fixed and cannot be changed. You do have to generate a new one once it expires, by either manually print it or by refresh token.

但是,当您需要快速访问Google API时,打印访问令牌方法用于测试和调试.在实际使用中,您应该使用服务帐户进行身份验证.请按照本教程 https://cloud.google.com/natural-language/automl/docs/tutorial ,其中包括设置服务帐户的步骤.

However, the print-access-token approach is for testing and debugging, when you need the quick access to Google APIs. In reality usage, you should use service account for authentication. Please follow this tutorial https://cloud.google.com/natural-language/automl/docs/tutorial, which includes the steps to setup service account.

这篇关于AutoML自然语言令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆