Chromeの拡張機能を使用してGoogleシートからデータを読み取ろうとしていますが、アクセストークンを取得できません。これまでに行ったことです:Chrome拡張機能からChrome ID API経由でGoogleスプレッドシートにアクセス
- Google APIコンソールでOAuth 2クライアントIDを作成しました。許可されたJavaScriptの起源に "http://localhost"と "https://localhost"を入力しました(私の拡張機能は現在localhostに入っているので)。 はChromeの拡張機能の
manifest.json
を含むように更新:
{
"permissions": [
"identity",
"https://docs.google.com/spreadsheets/"
],
"oauth2": {
"client_id": "<enter-oauth2-client-id-here>",
"scopes": [
"https://docs.google.com/spreadsheets"
]
}
}
- を追加しました。この時点で、バックグラウンドスクリプト
console.log("here"); // this point is hit
var ci = chrome.identity;
ci.getAuthToken({ interactive: true }, function(token) {
console.log("token: " + token); // none of this is hit
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError);
return;
}
access_token = token;
});
に次のコード、私は拡張子をリロードし、Chromeを私の資格情報を要求します(ci.getAuthToken({ interactive: true } ...)
行が実行されます)。しかし、資格情報が正常に提供されると、他には何も起こりませんペン。私はトークンが決して検索されないと思うので、function(token){...}
内のコードは実行されません。バックグラウンドコンソールには「ここ」のメッセージが表示されますが、その他のエラーは表示されません(何もエラーや警告などは表示されません)。
注:manifest.json
のoauth2:client_id
の下に、私はGoogle APIコンソールで生成されたOAuth2クライアントIDを使用しています。
私には何が欠けていますか?
に
を変更_あまり意味がありません。あなたはどういう意味ですか? – Xan
これはどの進歩ですか? –