我正在与谷歌功能与$cordovaOauth.google插件登录工作。但是我得到了unsupported_response_type错误。
$cordovaOauth.google("MY_APP_ID", ["https://www.googleapis.com/auth/urlshortener", "https://www.googleapis.com/auth/userinfo.email"]).then(function (result) {
console.log(JSON.stringify(result));
alert(JSON.stringify(result));
$scope.gdata = result;
}, function (error) {
console.log(error);
});
我犯错了!?
发布于 2015-12-02 12:21:33
是的,因为$cordovaOauth
插件加载网页视图,所以你必须从谷歌应用程序接口网页clientID。这对ionic (移动应用)不起作用,所以你需要做以下事情。
First
您需要使用应用程序的方案来提供内部URL,如google://
或twitter://
参考: http://mcgivery.com/using-custom-url-schemes-ionic-framework-app/
并在Google重定向URL中提供自定义url (这并不总是有效的,因为Google不接受自定义URL,但您可以尝试一下)。
的第二个和可行的解决方案:
您需要使用您的应用程序标识符和keytool创建Google应用程序。
适用于安卓的 :
https://developers.google.com/identity/sign-in/android/start遵循第二步,并提供您的应用程序名称和唯一标识符(即dipesh.cool.com )
iOS的 :
https://developers.google.com/mobile/add?platform=ios&cntapi=signin
与android中提到的信息相同。
然后,您需要从配置文件中获取REVERSED_CLIENT_ID
值,完成上述两个步骤后,即可下载该配置文件(您可以从iOS配置文件中获取该值,该文件很容易找到)。
然后简单地运行下面的命令和代码,你就会得到所有的工作。
命令:
cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=GRAB_THIS_FROM_IOS_OR_ANDROID_CONFIG_FILE
角度代码:
$scope.GoogleLogin = function()
{
$scope.loaderShow('Google');
window.plugins.googleplus.login({},function (obj)
{
window.localStorage.setItem('signin', 'Google');
window.localStorage.setItem('g_uid', obj.userId);
window.localStorage.setItem('g_fname', obj.givenName);
window.localStorage.setItem('g_lname', obj.familyName);
window.localStorage.setItem('user_full_name', obj.displayName);
window.localStorage.setItem('g_email', obj.email);
window.localStorage.setItem('gotPdetails', 'false');
$scope.loaderHide();
$state.go('app.dashboard');
},
function (msg)
{
$scope.showAlert('Google signin Error<br/>'+msg);
$scope.loaderHide();
});
}
https://stackoverflow.com/questions/30572219
复制相似问题