Windows cURL 获取 Openstack Swift Token

1. Download CURL for Windows from https://curl.haxx.se/windows/ 

2. Extract it to a place, such as "C:\Program Files\".

3. Open CMD and cd to "C:\Program Files\curl-7.69.1-win64-mingw\bin"

4. Run "curl xxx" same as in Linux.



Notice the differences from using in Linux:

1. The \ which indicating a same line doesn't apply anymore.

2. All the ' should be replaced with ".

3. All the data part (after -d, and inside ""), should replace " with \".

 

For example:

In Linux, the comand looks like:

curl -i \
  -H "Content-Type: application/json" \
  -d '
{ "auth": {
    "identity": {
      "methods": ["password"],
      "password": {
        "user": {
          "name": "user",
          "domain": { "id": "default" },
          "password": "root"
        }
      }
    },
    "scope": {
      "project": {
        "name": "admin",
        "domain": { "id": "default" }
      }
    }
  }
}' -k \
  "https://1.1.1.10:5000/v3/auth/tokens"



In Windows, it should be transferred to 

curl -i   -H "Content-Type: application/json" -d "{\"auth\":{\"identity\":{\"methods\":[\"password\"],\"password\":{\"user\": {\"name\": \"user\",\"domain\":{\"id\":\"default\"},\"password\":\"root\"}}},\"scope\":{\"project\":{\"name\": \"admin\",\"domain\":{\"id\": \"default\" }}}}}" -k "https://1.1.1.10:5000/v3/auth/tokens"

posted on 2020-08-25 13:30  liujx2019  阅读(161)  评论(0编辑  收藏  举报

导航