GIS云套件

tokens

URI

http://{server}:{port}/manager/web/api/token

支持的方法

POST

介绍

根据账户信息获取token,没有token不能访问GIS云套件。

支持的表述格式:JSON。

HTTP 请求方法

对如下 URI 执行 HTTP 请求,其中,{server}是服务网关的服务器名,需用实际网关IP替换;{port}是网关端口,需用实际网关端口替换。

http://{server}:{port}/manager/web/api/token

Post 请求

用户获取 token。

请求头格式

content-type: application/json

请求参数

获取 Token 时应在请求体中传递如下参数:

名称 类型 含义
userName String 用户名
password String 用户密码

响应结构

名称 说明
access_token 获取到的凭证
refresh_token 凭证过期后用于获取新的凭证
refresh_expires_in 刷新凭证过期时间;单位:秒
token_type 凭证种类
expires_in 凭证有效时间;单位:秒

响应示例

对 tokens 资源执行 POST 请求,URL:http://192.168.17.139:32507/manager/web/api/token,如下所示:

请求头:

content-type: application/json

请求体:

{
  "userName":"user_admin",
  "password":"iserver"
}

返回的内容如下:

{
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJNRnpGNG9lalI2ZGJiR2xVZWYtUi1xa1M0RWF4TThJU1lOTkpNc1dROTVFIn0.eyJqdGkiOiI1ZTI3MjFmNi1iMGI1LTQ2MzYtOGRlZi1kYTE2NzEzOWVjZWYiLCJleHAiOjE1NTcxMDQyODEsIm5iZiI6MCwiaWF0IjoxNTU3MTAzOTgxLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xNy4xMzk6MzI1NDEvYXV0aC9yZWFsbXMvaXNwZWNvIiwiYXVkIjoiaXNwZWNvLWRhc2hib2FyZC1hcGkiLCJzdWIiOiJhMDk4ZTNiZS1iZGMwLTQ4ODQtOTk2NC04MWZlMjVjNTE3MmYiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJpc3BlY28tZGFzaGJvYXJkLWFwaSIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImYzNzZkZjcxLTgwOWEtNDYwOS1hOWZmLWZjZGU0NmRhNDAzYiIsImFjciI6I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2hib2FyZC1hcGkiLCJzdWIiOiJhMDk4ZTNiZS1iZGMwLTQ4ODQtOTk2NC04MWZlMjVjNTE3MmYiLCJ0eXAiOiJSZWZyZXNoIiwiYXpwIjoiaXNwZWNvLWRhc2hib2FyZC1hcGkiLCJhdXRoX3RpbWUiOjAsInNlc3Npb25fc3RhdGUiOiJmMzc2ZGY3MS04MDlhLTQ2MDktYTlmZi1mY2RlNDZkYTQwM2IiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiYnVpbHRpbiIsIm9mZmxpbmVfYWNjZXNzIiwiQURNSU4iLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSJ9.vZRLjw4XaThk1i573zInoGLdJdtHGbCUxAyYu0n8uOU",
    "refresh_expires_in": 1800,
    "not-before-policy": 0,
    "scope": "email profile",
    "token_type": "bearer",
    "session_state": "f376df71-809a-4609-a9ff-fcde46da403b",
    "expires_in": 300
}

得到类似以上的返回内容,则成功获取token,token为“access_token”中的内容。有了access_token,用户才可以使用GIS云套件。

使用token

通过POST请求获取access_token后,在未登录的状态下执行资源请求,以http://{server}:{port}/manager/web/api/service/nodes为例。有三种实现资源请求的方式:Authroization Header、Form-Encoded Body Parameter、URI Query Parameter,这三种方式按优先级依次递减。

注:
access_token的有效时间为五分钟。token过期后,请用refresh_token获取新的token(refresh_token有效时间为三十分钟),或重新获取access_token。

Authorization Header

请求头格式:

GET resource HTTP/1.1

content-type: application/json
Authorization: Bearer {access_token}

实例:

GET http://192.168.17.139:32507/manager/web/api/service/nodes

content-type: application/json
authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJNRnpGNG9lalI2ZGJiR2xVZWYtUi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ah2DX7Yo4k2vXPohOXe3zjCnx7e0tisMX7eYGn0x6sBstmqIYDDnJ9bodyGFOYoMFrA4xrOtOufuJ3uiIxtkJOGmGuDm2w_UhswgY67Yn5NqPi-gtzEYd0c2NcoIWSfX5db0zEuKYepeqE4s_HcQRAAX_ZJy9eg

返回的 json格式的响应结果如下:

[
    {
      "nodeName": "Node",
      "nodeType": null,
      "featureIds": null,
      "instanceNumber": 0,
      "serviceInfos": [
        {
          "componentName": "map-China400-d3awywrtby",
          "interfaceName": "rest",
          "name": "Instance-map-China400-d3awywrtby-rest",
          "providerName": "Provider-map-China400-d3awywrtby",
          "dataSourceType": "workspace",
          "serviceType": "map-rest"
        }
      ],
      "available": true
    }
]

Form-Encoded Body Parameter

当客户端无法使用Authorization Header时,使用该方法。

请求头格式:

POST {resource} HTTP/1.1

content-type: application/x-www-form-urlencoded

请求体格式:

access_token={access_token}

注:
Form-Encoded Body Parameter不支持GET请求,请求体必须遵循application/x-www-form-urlencoded编码,不支持Json等格式,参数间以“&”隔开。

URI Query Parameter

当以上两种方式都无法请求时,使用该方法:

请求头格式:

GET {resource}?access_token={access_token} HTTP/1.1

Cache-Control: no-store

实例:

Get http://192.168.17.139:32507/manager/web/api/service/nodes?access_token=eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJNRnpGNG9lalI2ZGJiR2xVZWYtUi1xa1M0RWF4TThJU1lOTkpNc1dROTVFIn0.eyJqdGkiOiI1ZTI3MjFmNi1iMGI1LTQ2MzYtOGRlZi1kYTE2NzEzOWVjZWYiLCJleHAiOjE1NTcxMDQyODEsIm5iZiI6MCwiaWF0IjoxNTU3MTAzOTgxLCJpc3MiOiJodHRwOi8vMTkyLjE2OC4xNy4xMzk6MzI1NDEvYXV0aC9yZWFsbXMvaXNwZWNvIiwiYXVkIjoiaXNwZWNvLWRhc2hib2FyZC1hcGkiLCJzdWIiOiJhMDk4ZTNiZS1iZGMwLTQ4ODQtOTk2NC04MWZlMjVjNTE3MmYiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJpc3BlY28tZGFzaGJvYXJkLWFwaSIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6ImYzNzZkZjcxLTgwOWEtNDYwOS1hOWZmLWZjZGU0NmRhNDAzYiIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiYnVpbHRpbiIsIm9mZmxpbmVfYWNjZXNzIiwiQURNSU4iLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoidXNlcl9hZG1pbiJ9.YWcFA4zQQMCCE_CO8qPWpRgzB1zhrFKJ5flC2mwBDJg_pJxkuye2Hd5JvxtsZwRqYcqb5ox33h2JF_kTHjIx1YmwyItOIR1Q13otUqXa3nltYCp3ixoHeC9vfNu0Dnqi55rteNnHD3ILKgaJBJLxS7n4FrZzHODHjnb4rJT6rCGt8DFRFyVE5Ibah2DX7Yo4k2vXPohOXe3zjCnx7e0tisMX7eYGn0x6sBstmqIYDDnJ9bodyGFOYoMFrA4xrOtOufuJ3uiIxtkJOGmGuDm2w_UhswgY67Yn5NqPi-gtzEYd0c2NcoIWSfX5db0zEuKYepeqE4s_HcQRAAX_ZJy9eg

Cache-Control: no-store

返回的json格式的响应结果如下:

[
    {
      "nodeName": "Node",
      "nodeType": null,
      "featureIds": null,
      "instanceNumber": 0,
      "serviceInfos": [
        {
          "componentName": "map-China400-d3awywrtby",
          "interfaceName": "rest",
          "name": "Instance-map-China400-d3awywrtby-rest",
          "providerName": "Provider-map-China400-d3awywrtby",
          "dataSourceType": "workspace",
          "serviceType": "map-rest"
        }
      ],
      "available": true
    }
]