【问题标题】:Invalid OAuth2 Client ID while chrome.identity.getAuthTokenchrome.identity.getAuthToken 时 OAuth2 客户端 ID 无效
【发布时间】:2015-06-29 08:13:14
【问题描述】:

我遵循了这个问题中给出的答案 - chrome.identity User Authentication in a Chrome Extension

我安装了扩展并从 chrome://extensions 复制了密钥并生成了一个客户端 ID

生成客户端ID和应用程序ID后,我将它们粘贴到manifest.json

我的manifest.json -

{

    "name": "Identity test",
    "version": "1",
    "manifest_version": 2,
    "background": {
        "scripts": ["background.js"]
    },  
    "permissions": [
        "identity"
    ],
     "oauth2": {
        "client_id": "575910104810-bip578sprqmaauj7cred8ejsf3cirs95.apps.googleusercontent.com",
        "scopes": [
            "https://www.googleapis.com/auth/userinfo.email"
        ]   
    },   
    "key":"mebmekhndfhnahepihccnkiaifobgdbi"

}

我的background.js-

chrome.identity.getAuthToken({
    interactive: true
}, function(token) {
    if (chrome.runtime.lastError) {
        alert(chrome.runtime.lastError.message);
        return;
    }
    var x = new XMLHttpRequest();
    x.open('GET', 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=' + token);
    x.onload = function() {
        alert(x.response);
    };
    x.send();
});

但我得到无效的 OAuth2 客户端 ID.Reason?

【问题讨论】:

    标签: google-chrome-extension google-api


    【解决方案1】:

    清单中"key" 字段的格式无效。

    这不是 ID,而是它的加密签名版本。

    请参阅herehere,了解如何获得正确的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-19
      • 2020-12-04
      • 2019-08-18
      • 2017-11-16
      • 1970-01-01
      • 1970-01-01
      • 2023-02-06
      • 1970-01-01
      相关资源
      最近更新 更多