Angularjs facebook重定向uri中应该实现什么?
我有一个带卫星的angular 1.5.0-rc0应用程序,可以登录facebook 该网站连接到位于的nodejs服务器 该网站是 要使用facebook配置satellizer,我有以下代码:Angularjs facebook重定向uri中应该实现什么?,angularjs,node.js,facebook,restify,satellizer,Angularjs,Node.js,Facebook,Restify,Satellizer,我有一个带卫星的angular 1.5.0-rc0应用程序,可以登录facebook 该网站连接到位于的nodejs服务器 该网站是 要使用facebook配置satellizer,我有以下代码: app.config(function($authProvider) { $authProvider.facebook({ clientId: '226393057557099', url: 'https://myalcoholist.
app.config(function($authProvider) {
$authProvider.facebook({
clientId: '226393057557099',
url: 'https://myalcoholist.com:8888/auth/facebook',
redirectUri: 'https://myalcoholist.com'
});
});
和我的登录控制器代码:
(function () {
angular.module('myalcoholist').controller('LoginController',['$scope','$auth','$location', 'toastr',function ($scope,$auth,$location,toastr) {
$scope.authenticate = function (provider) {
$auth.authenticate(provider).then(function () {
toastr.success('You have successfully signed in with ' + provider + '!');
$location.path('/');
})
.catch(function (error) {
if (error.error) {
// Popup error - invalid redirect_uri, pressed cancel button, etc.
toastr.error(error.error);
} else if (error.data) {
toastr.error(error.data.message, error.status);
} else {
toastr.error(error);
}
}
)
}
}]);
})();
我的nodejs应用程序使用restify框架来处理请求
我将其配置为路由:
server.post('/auth/:provider', function (req,res,next) {
require(post_commands_dir + 'auth.js')(req,res,next);
})
而auth.js包含
var FB = require('fb');
function auth(req, res, next) {
var clientId = req.params.clientId;
var code = req.params.code;
var provider = req.params.provider;
FB.api('oauth/access_token', {
client_id: '<CLIENT_ID>',
client_secret: '<CLIENT_SECRET>',
redirect_uri: 'https://myalcoholist.com',
code: code
}, function (response) {
if(!response || response.error) {
console.log(!response ? 'error occurred' : response.error);
return;
}
var accessToken = response.access_token;
res.send(JSON.stringify({token:accessToken}));
// var expires = response.expires ? response.expires : 0;
});
}
module.exports = auth;
现在在facebook控制台中,我将有效的OAuth重定向URI
配置为
现在我认为我可能弄错了重定向uri,我应该以不同的方式实现它。我只是不知道怎么做。有什么想法吗?当我添加
https://myalcoholist.com
自动添加到OAuth回调Url中。这就是我在API服务器中缺少的东西。api服务器中的重定向url配置为https://myalcoholist.com
不带结尾/
welp问题已解决。登录对话框调用中使用的重定向URI是什么?@CBroe我将其配置为登录对话框URL中参数的实际值?@CBroe-谢谢帮助。我找到了解决办法。
{ message: 'Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request',
type: 'OAuthException',
code: 100,
fbtrace_id: 'B09qSPJS08d' }