Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS调用Google OAuth2_Javascript_Angularjs_Oauth 2.0 - Fatal编程技术网

Javascript AngularJS调用Google OAuth2

Javascript AngularJS调用Google OAuth2,javascript,angularjs,oauth-2.0,Javascript,Angularjs,Oauth 2.0,当我打这个电话时,它会打开帐户选择器,然后我可以选择我的一个谷歌帐户,当我这样做时,我会得到错误 Error: invalid_request Missing required parameter: scope 我可以在帐户选择器的URL中看到范围变量,但当我选择帐户时,它会丢失URL中的范围变量。在本例中,我更改了我的客户端ID。 提前谢谢 app.controller("FirstController", function($scope, $location) { $scope.red

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

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);
}

}))

使用AngularJS$定位服务的方法是:

var location = $location.url(url);

有关详细信息,请参见

我尝试了此操作,也尝试了$location.path,我正在将对象返回到变量位置,但现在没有显示任何内容。我将此更改为$location.url(url)和$location.path(url),我将此更改为$location.url(url)和$location.path(url)$$path:“$$url:/”