我一直在关注https://github.com/rfdickerson/watson-translation-demo,它试图展示如何在iOS上使用Facebook OAuth和NodeJS后端进行身份验证。
iOS代码很简单:
let token: String = FBSDKAccessToken.currentAccessToken().tokenString
let fbAccess = FacebookAuthenticationStrategy(
tokenURL: "https://watsonsdkdemo.mybluemix.net/language-translation-service/api/v1/token",
fbToken: token)
translateService = LanguageTranslation(authStrategy: fbAccess)
问题是server / app.js有
var creds = appEnv.getServiceCreds(/facebook-authentication/) || {}
并且manifest.yml有
- services:
- facebook-authentication
但是,当你{4}}到你的Bluemix帐户的脚本时,你会得到:
cf push
问题是作者没有描述'facebook-authentication'服务是什么。
在服务器部署说明中
FAILED
Could not find service facebook-authentication to bind to xxxxxxx
没有说明facebook认证服务是什么。
答案 0 :(得分:0)
我很抱歉说明不完整。 facebook-authentication应该是用户提供的服务。您可以使用cf create-user-provided-service command:
创建它cf create-user-provided-service facebook-authentication -p" APP_SECRET_GOES_HERE"
这个想法是,当你注册Facebook应用程序时,他们会给你一个App Secret。由于该秘密不应嵌入源代码中,您可以通过创建为您提供该信息的自定义服务在环境变量VCAP中进行设置。
注意,我没有完成使用app secret检查凭据的合法性。虽然这是针对中间人攻击的一个小安全漏洞,但facebook令牌检查仍然有效,因为在Facebook App设置中我这样做是为了不需要使用App秘密。现在,只需创建用户服务并将值设置为您想要的任何值。
希望这有帮助!