IOS Facebook身份验证使用node.js passport-facebook-token

我正在尝试使用来自 IOS应用程序的 passport-facebook-token对node.js api进行身份验证.

我有用户名密码验证设置,并通过护照和护照-facebook-token设置正常工作.

passport.use(new FacebookTokenStrategy({
clientID: config.facebook.clientID,clientSecret: config.facebook.clientSecret
},function(accesstoken,refreshToken,profile,done) {
User.findOrCreate({ facebookId: profile.id },function (err,user) {
return done(err,user);
});

我只是无法弄清楚将访问令牌发送到API所需的HTTP请求语法.

任何帮助都将受到大力赞赏.

谢谢.

解决方法

确定设法从passport-facebook-token的策略文件中找出答案

这个需要:

http:// URL?access_token = [访问令牌]

从IOS我只是用以下方法测试:

Nsstring *fbAccesstoken = [[[FBSession activeSession] accesstokenData] accesstoken];
NSLog(@"This is token: %@",fbAccesstoken);        
NSURL *url = [NSURL URLWithString:[Nsstring stringWithFormat:@"http://myapi.url.com/auth/facebook?access_token=%@",fbAccesstoken]];
NSMutableuRLRequest *req = [[NSMutableuRLRequest alloc] initWithURL:url];
[req setHTTPMethod:@"GET"];
dispatch_async(dispatch_get_global_queue(disPATCH_QUEUE_PRIORITY_DEFAULT,0),^{
NSURLResponse *res;
NSError *err;
[NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&err];
if (!err) {
NSLog(@"The user is logged in on the server side too");
} else {
NSLog(@"Error occurred. %@",err);
}
});

希望这有助于其他人.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...