如何使用访问令牌绕过FB.login() [英] How can I use an access token to circumvent FB.login()

查看:102
本文介绍了如何使用访问令牌绕过FB.login()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用手机间隙将我们的HTML5应用程序包装到原生iOS应用程序中。
我们需要登录到Facebook,但是JS SDK会弹出一个移动Safari窗口,从那里返回应用程序有点奇怪。

We are using phonegap to wrap our HTML5 app into a native iOS application. We need to login to facebook, but the JS SDK will pop up a Mobile Safari window and, from there, it's a bit weird to go back to the app.

我们要做的是使用Facebook的iOS SDK并获得访问令牌,然后以某种方式在我们的JS代码中使用该令牌来验证用户。

What we want to do is use Facebook's iOS SDK and get an access token and then somehow use that token in our JS code to authenticate the user.

显然,我们仍然希望使用已经认为需要令牌的JS SDK。

Obviously, we still want to use the JS SDK which has been thought out to not need tokens.

你知道吗我们该怎么做?

Do you know how we could do that?

推荐答案

尝试

FB._authResponse.accessToken = 'YOUR TOKEN RETRIEVED FROM iOS SDK'

so访问您的应用程序所在的UIWebView:

so with access to the UIWebView where your application lives:

[webView stringByEvaluatingJavaScriptFromString:
                              @"FB._authResponse.accessToken = '%@'",accessToken]

这篇关于如何使用访问令牌绕过FB.login()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆