Google URL Shortener API 403禁止使用

Ome*_*dar 5 javascript google-api node.js google-url-shortener google-oauth

我最近一直在探索谷歌API,并一直在玩他们的URL缩短API.我正在使用oAuth进行身份验证,并将该部分记录下来.我成功地使用了API的get和list函数,但是在使插入函数工作时遇到了问题.

const {google} = require('googleapis');

const urlshortener = google.urlshortener({
    version: 'v1',
    auth: auth
});

async function insert(lengthened) {
    return await urlshortener.url.insert({
        requestBody: {
            longUrl: lengthened
        },
        fields: 'id'
    });
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,auth只是一个已经过身份验证的google oauth客户端,它从另一个文件传入.

奇怪的是,当我尝试调用此函数时,我收到以下错误:

[ { domain: 'global', reason: 'forbidden', message: 'Forbidden' } ] 
Run Code Online (Sandbox Code Playgroud)

我已经扫描了其余的响应,但没有找到任何其他信息.这对我来说很奇怪,因为其他两个函数都有效,我正在使用oAuth,因此API密钥限制应该没有问题,并且其他两个API方法都有效.

我的oAuth认证范围:

https://www.googleapis.com/auth/urlshortener
Run Code Online (Sandbox Code Playgroud)

Ome*_*dar 1

正如对原始问题的评论中所指出的。Google 将停止对其 URL 缩短程序的支持。这就是为什么可以使用此库检索数据,而不能创建新的缩短的 URL。