如何以本地应用程序方式获取Facebook测试用户令牌 [英] How to get a facebook test user token programatically for a native app

查看:144
本文介绍了如何以本地应用程序方式获取Facebook测试用户令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发由服务器支持的iPhone应用程序。服务器与Facebook进行通话,以推动Opengraph活动。我试图测试这个代码。我在Web界面中创建了Facebook测试用户。如果我为他们手动生成令牌,它们将生成24小时到期,这使得它们对测试无用。所以我需要在测试代码中根据需要生成令牌。 Facebook开发者文档 https://developers.facebook.com/docs/test_users/ 说我可以让帐户/测试用户列出测试用户及其令牌。但是,当我这样做时,我得到这个:

We're developing an iPhone app backed by a server. The server talks to Facebook in order to push Opengraph events. I'm trying to test this code. I've created Facebook test users in the web interface. If I manually generate tokens for them they get generated with a 24 hour expiry, which render them useless for the tests. So I need to generate the tokens on demand in the testcode. The Facebook developer docs https://developers.facebook.com/docs/test_users/ say I can get accounts/test-users to list the test users and their tokens. However when I do that I get this:

{
    error: {
        message: "(#15) This method is not supported for native apps",
        type: "OAuthException",
        code: 15
    }
}

我认为这是因为我们正在开发一个iPhone应用程序(尽管在Facebook应用程序配置中,我们配置了网站,Facebook应用程序和ios应用程序部分)。

I presume this is because we are developing an iPhone app (although in the Facebook app config we have the website, facebook app and ios app sections configured).

是否有一些设置需要更改才能使这项工作?还是生成令牌的其他一些方法?或手动生成可以硬编码到测试中的较长寿命令牌的方法?

Is there some setting I need to change to make this work? Or some other way of generating the tokens? or a way of manually generating longer lived tokens that could be hard coded into the tests?

推荐答案

是 - 更改应用模式'设置在高级设置回到'Web' - 如果应用程序秘密嵌入在客户端二进制文件中,您应该只使用本机/桌面。

Yes - change the 'App Mode' setting under advanced settings back to 'Web' - you should only use 'Native/Desktop' if the app secret is embedded in the client binary.

当此设置设置为本机/桌面时,应用程序秘密不受信任,因为您的任何用户都可以从客户端代码中提取密码,并代表该应用程序

When this setting is set to 'Native/Desktop' the app secret is untrusted because any of your users could extract the secret from the client code and make calls on behalf of the app

这篇关于如何以本地应用程序方式获取Facebook测试用户令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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