我一直在关注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但是,当您将脚本cf push到您的Bluemix帐户时,您会得到:
FAILED
Could not find service facebook-authentication to bind to xxxxxxx问题是作者并没有描述什么是“facebook认证”服务。
在服务器部署说明中,他们有
$ cf login
$ cf create-service speech_to_text standard speech-to-text-service
$ cf create-service text_to_speech standard text-to-speech-service
$ cf create-service language_translation standard language-translation-service
$ cf env
$ cd server
$ cf push没有说明什么是facebook身份验证服务。
发布于 2016-01-23 04:58:19
我很抱歉,说明不完整。facebook-authentication应该是用户提供的服务。您可以使用cf create-user-provided-service command创建它
cf创建用户提供的服务facebook身份验证-p "APP_SECRET_GOES_HERE“
这个想法是,当你注册一个Facebook应用程序时,他们会给你一个App Secret。由于该秘密不应该嵌入到源代码中,因此您可以通过创建一个为您提供该信息的自定义服务,在环境变量VCAP中设置它。
请注意,我实际上并没有完成使用应用程序密钥来检查凭据的合法性。虽然这是中间人攻击的一个小安全漏洞,但facebook令牌检查仍然有效,因为在Facebook应用程序设置中,我进行了检查,因此不需要使用应用程序密钥。现在,只需创建用户服务并将值设置为您想要的任何值即可。
希望这能有所帮助!
https://stackoverflow.com/questions/34932425
复制相似问题