gpt4 book ai didi

javascript - 必须同时提供 client_id 和 scope 来初始化 OAuth

转载 作者:行者123 更新时间:2023-12-05 00:33:19 24 4
gpt4 key购买 nike

我正在工作 Google Sheets API Javascript Quickstart并且遇到了 gapi.client.init() 的身份验证问题.

这是给我问题的代码:

// Client ID and API key from the Developer Console
var CLIENT_ID = "50m3-cle3nt-1d.apps.googleusercontent.com";
var API_KEY = "AIzaN0tRe4lLyAn4pIk5y";

// Array of API discovery doc URLs for APIs used by the quickstart
var DISCOVERY_DOCS = ["https://sheets.googleapis.com/$discovery/rest?version=v4"];

// Authorization scopes required by the API; multiple scopes can be
// included, separated by spaces.
var SCOPES = "https://www.googleapis.com/auth/spreadsheets.readonly";

function initClient() {
gapi.client.init({
apiKey: API_KEY,
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES
}).then(function() {
// doesn't matter.
})
}

我无法获得 init()打电话上类,即使我尝试调用 init(),我也会收到问题标题中的错误在控制台内部独立:
> k = gapi.client.init({ ... })
client_id and scope must both be provided to initialize OAuth

我在调用 init() 时遗漏了什么?

任何提示将不胜感激。

最佳答案

我也面临同样的问题。
initClient我替换的函数gapi.client.initgapi.auth2.init它奏效了。

关于javascript - 必须同时提供 client_id 和 scope 来初始化 OAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43830848/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com