这是对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\"}"
答案 0 :(得分:1)
在这一行 -
request = Net::HTTP::Post.new(uri.request_uri, {'Authorization' => 'Bearer #{form.auth_token}', 'Content-Type' => 'application/json'})
尝试使用双引号将该授权字符串更改为"Bearer #{form.auth_token}"
。字符串插值仅适用于双引号字符串。