chrome.identity.launchWebAuthFlow的正确重定向网址是什么?

时间:2013-08-19 10:57:43

标签: javascript oauth-2.0 dart github-api google-chrome-app

我想在Chrome打包应用中使用chrome.identity API,以允许用户通过github进行身份验证。

从应用方面来说,我很满意:

chrome.identity.launchWebAuthFlow(
  {'url':'https://github.com/login/oauth/authorize?client_id=clientidgoeshere','interactive':true}, 
  functionToTakeRedirectURL
);

但我不确定github端的重定向URL应该是什么。当应用程序处于活动状态时,我会在github应用程序页面上将重定向URL设置为https://appidgoeshere.chromiumapp.org,但在应用程序运行之前,我认为该URL不可用。

在您撰写应用时,有人知道在哪里指向重定向吗?

我正在使用chrome.dart库在Dart中编写应用程序,但我认为如果我使用普通的javascript编写,则存在同样的问题。

2 个答案:

答案 0 :(得分:10)

您可以使用chrome.identity.getRedirectURL,因此您无需在应用中对重定向网址模式进行硬编码。

答案 1 :(得分:6)

github auth chrome app sample使用chrome.runtime.id来构建重定向网址:

 var redirectUri = 'https://' + chrome.runtime.id +
                  '.chromiumapp.org/provider_cb';

参考文献:

相关问题