【问题标题】:AngularJS call to Google OAuth2AngularJS 调用 Google OAuth2
【发布时间】:2015-11-22 05:37:02
【问题描述】:

当我拨打这个电话时,它会打开帐户选择器,然后我可以选择我的一个谷歌帐户,当我这样做时,我会收到错误

Error: invalid_request

Missing required parameter: scope

我可以在帐户选择器的 URL 中看到范围变量,但是当我选择帐户时,它会丢失 URL 中的范围变量。在此示例中,我更改了我的客户 ID。 提前致谢。

 app.controller("FirstController", function($scope, $location) {
$scope.redirectToGoogle = function () {
    console.log("redirectToGoogle");
    var client_id="myclientID";
    var scope="profile email";
    var redirect_uri="http://localhost:8080/auth/google/callback/";
    var response_type="token";
    var url="https://accounts.google.com/o/oauth2/auth?&client_id="+client_id+"scope="+scope+"&redirect_uri="+redirect_uri+"&response_type="+response_type;
    window.location.replace(url);
}

});

【问题讨论】:

标签: javascript angularjs oauth-2.0


【解决方案1】:

使用 AngularJS $location 服务的方法是:

var location = $location.url(url);

欲了解更多信息,请参阅AngularJS $location service API Docs

【讨论】:

  • 我试过这个,也用 $location.path 并且我将对象返回到变量位置,但现在什么都没有显示。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-03
  • 2012-12-18
  • 2017-06-12
  • 1970-01-01
  • 2015-01-30
  • 1970-01-01
相关资源
最近更新 更多