如何以编程方式获取本机应用程序的Facebook测试用户令牌

如何以编程方式获取本机应用程序的Facebook测试用户令牌

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

问题描述

我们正在开发由服务器支持的iPhone应用程序.服务器与Facebook对话以推送Opengraph事件.我正在尝试测试此代码.我已经在网络界面中创建了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?

推荐答案

是-将高级设置下的应用程序模式"设置更改为网络"-如果嵌入了应用程序密码,则只能使用本机/桌面"在客户端二进制文件中.

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测试用户令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 21:30