Google API机器学习可以使用API​​密钥吗? [英] google api machine learning can I use an API KEY?

查看:105
本文介绍了Google API机器学习可以使用API​​密钥吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于学习目的,我正在尝试使用机器学习(ml)API.

For learning purposes, I'm trying to use the Machine learning (ml) API.

https://cloud.google.com /ml-engine/reference/rest/v1/projects.models/list

我无法确定是否可以使用API​​ KEY(而不是OAUTH)完成此请求.

I'm not able to identify if this request can be done with an API KEY instead of OAUTH.

我正在与此一起使用npm包googleapis

I'm using npm package googleapis with this;

ml.projects.models.list({
    key: GCLOUD_API,
    parent: "projects/"+GCLOUD_PROJECT
  }

但总是会收到此错误:

请求缺少必需的身份验证凭据.预期的OAuth 2访问令牌,登录cookie或其他有效的身份验证凭据

Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential

我尝试用authtoken替换key.没事.

I've tried replacing key with auth or token. Nothing work.

我怎么知道是否可以使用api密钥?

How can I know if is possible or not to use an api key?

我也尝试过卷曲

'https://ml.googleapis.com/v1/projects/myproject-123456/models?token=my_super_sekret_key'

推荐答案

今天我也有同样的疑问.

Today I had the same doubt.

以下是支持API密钥的GCP服务: https://cloud.google.com/docs/authentication/api-keys并且不包含ML API.

Here are GCP Services that support API Keys: https://cloud.google.com/docs/authentication/api-keys and ML API is not included.

您应该使用OAuth2获取访问令牌,因此URL POST请求将为:

You should obtain the access token using OAuth2, so URL POST request will be:

https://ml.googleapis.com/v1/projects /your_project/models?access_token = your_access_token

对我来说很棒.与做预测一样.

Works great for me. Same to do predictions.

这篇关于Google API机器学习可以使用API​​密钥吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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