【问题标题】:chrome.identity.getRedirectURL has a different app-id on different computerschrome.identity.getRedirectURL 在不同的电脑上有不同的app-id
【发布时间】:2016-11-16 10:52:03
【问题描述】:

为了让 OAUTH 正常工作,每次我在不同的计算机上运行时,get 重定向 url 都会发生变化。

var redirectUri = chrome.identity.getRedirectURL("https://www.google.com/"); 

那是我用来生成它的代码,但是它以https://[app-id].chromiumapp.org/*. 的形式返回的app id,在不同的计算机上有不同的app-id。

这是一个问题,因为我必须在我正在使用的 API 站点上注册重定向 url,但每个人都不同。

这是完整的代码块

var redirectUri = chrome.identity.getRedirectURL("https://www.google.com/"); 
var auth_url = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&redirect_uri=" + redirectUri + "&scope=user-library-modify%20user-read-email&response_type=token&state=123";
chrome.identity.launchWebAuthFlow({'url':auth_url,'interactive':true}, function(redirect_url){
    console.log(redirect_url)
});

硬编码也没有用

【问题讨论】:

    标签: javascript google-chrome authentication google-chrome-extension oauth


    【解决方案1】:

    仅当您将扩展加载为未打包时,应用 ID 才会更改,并且 its folder has a different absolute path

    有两种方法可以固定 ID:

    1. 将其发布到网上应用店。这将为从商店安装的用户固定 ID。
    2. "key" 字段添加到清单。 This question 是一个很好的切入点。

    【讨论】:

    • 再次感谢 Xan!您是如何像学习 chrome 扩展程序和 javascript 一样多地学习的?您似乎已经回答了关于 SO 的几乎所有 Chrome 扩展问题
    • 老实说,我不知道。我刚开始回答有关扩展程序和应用程序的问题。并在此过程中学到了很多东西。
    猜你喜欢
    • 1970-01-01
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 2023-04-03
    • 1970-01-01
    • 2019-01-22
    • 2013-04-19
    相关资源
    最近更新 更多