【问题标题】:Watson iOS SDK authenticationWatson iOS SDK 身份验证
【发布时间】:2016-04-28 05:02:55
【问题描述】:

我一直在查看 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-authentication”服务是什么。

在他们的服务器部署说明中

$ 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-authentication 服务。

【问题讨论】:

  • 我给repo的作者发了消息,请他回复。

标签: ios facebook oauth-2.0 ibm-cloud ibm-watson


【解决方案1】:

对于说明不完整,我深表歉意。 facebook-authentication 应该是用户提供的服务。您可以使用cf create-user-provided-service command 创建它:

cf create-user-provided-service facebook-authentication -p "APP_SECRET_GOES_HERE"

这个想法是,当您注册 Facebook 应用程序时,他们会给您一个 App Secret。由于该机密不应嵌入到源代码中,因此您可以通过创建为您提供该信息的自定义服务将其设置在环境变量 VCAP 中。

注意,我并没有完成实际使用应用程序密码来检查凭据的合法性。虽然这是一个针对中间人攻击的小安全漏洞,但 facebook 令牌检查仍然有效,因为在 Facebook 应用程序设置中我做了它,因此不需要使用应用程序密码。现在,只需创建用户服务并将值设置为您想要的任何值。

希望这会有所帮助!

【讨论】:

  • 好的,可以了!当我在命令行上提供“APP_SECRET_GOES_HERE”时,无论出于何种原因,它都会给我一个“>”提示。在检查命令帮助时,它似乎说它就像 cf create-user-provided-service my-db-mine -p '{"username":"admin","password":"pa55woRD"}' 实际上我输入了 exit > 提示并在 bluemix Web 界面环境变量中显示为 "user-provided": [ { "name": "facebook-authentication", "label": "user-provided", "credentials": { "APP_SECRET_GOES_HERE ": "退出" } } ]
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-10
  • 2013-08-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多