0

这是对 Usergrid-stack Web 应用程序的调用以创建新应用程序:

curl -H "Authorization: Bearer <auth_token>" \
     -H "Content-Type: application/json" \
     -X POST -d '{ "name":"myapp" }' \
     http://<node ip>:8080/management/orgs/<org_name>/apps

这是我的 Ruby 代码:

uri = URI.parse("http://#{server.ipv4_address}:8080/management/orgs/#{form.org_name}/apps")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, {'Authorization' => 'Bearer #{form.auth_token}', 'Content-Type' => 'application/json'})
request.set_form({"name" => form.app_name})
command.output.puts uri.request_uri
response = http.request(request)

目前我从服务器得到这个响应:

{\"error\":\"auth_unverified_oath\",\"timestamp\":1383613556291,\"duration\":0,\"exception\":\"org.usergrid.rest.exceptions.SecurityException\",\"error_description\":\"Unable to authenticate OAuth credentials\"}"
4

1 回答 1

1

在这一行——

request = Net::HTTP::Post.new(uri.request_uri, {'Authorization' => 'Bearer #{form.auth_token}', 'Content-Type' => 'application/json'})

尝试将该授权字符串更改为"Bearer #{form.auth_token}"-- 带双引号。字符串插值仅适用于双引号字符串。

于 2013-11-05T19:35:29.573 回答