核心概念

所有操作连接API都需要一个令牌(token),令牌将标识一个操作的调用者身份。系统将检查请求令牌之前执行的有效性。 一个错误的、无效的或过期的令牌将导致操作失败。
客户获得令牌验证自己后可使用OAuth2授权流。大多数客户端应用程序必须提供Client id、Client_secret、VCG用户名及密钥。

为了保证某些操作的安全,这些操作必须调用一个SSL和一个令牌,如OAuth2,我们通过令牌和SSL阻止“攻击者”。攻击者可能从非ssl链接嗅探令牌,然后使用令牌模拟客户从而获得敏感信息。
我们使敏感数据只接受令牌通过SSL调用。只要这些令牌总是经过SSL,攻击者则无法获得一个令牌来模拟一个客户。任何调用令牌在一个非SSL连接的操作将导致报错。

Token在获得120分钟后过期。根据OAuth2流程,您会收到一个刷新令牌(refresh_token)指令作为OAuth2的一部分,您可以用来刷新token。您可以在token到期之前进行更新会话操作,这样无需再次提供凭证。我们建议客户跟踪每个令牌的过期时间并主动刷新token。

获取访问令牌(Access token)

根据用户的client id、client secret、username、password以及grant type获取access token。

接口地址(URI):/api/oauth2/access_token

HTTP请求方式:POST

请求参数:
请求值字段 必选 类型 Parameter Type 说明
client_id true String formData API用户鉴权 id;申请API时分配的API Key
client_secret true String formData 申请API时分配的密钥
username true String formData 您的VCG账户名
password true String formData 您的VCG账户密码
grant_type true String formData 请求的类型,统一填写:authorization_code
请求参数示例example value:
Curl:curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'client_id=aaa&client_secret=bbb&username=test&password=xxxxx&grant_type=authorization_code' 'https://api.fotomore.com/api/oauth2/access_token'

Request URL:https://api.fotomore.com/api/oauth2/access_token

返回数据示例example value:
{
"refresh_token": "33a86d3c0a844566978d828f9c52b541",
"token_type": "bearer",
"expires_in": 687,
"access_token": "a08d2b1a92abead6a5b8eebff74e148d06c66548b6b9556779d43ee64c"
}
返回值字段 字段说明
access_token 用户授权的唯一票据,用于调用接口,同时也是第三方应用验证用户登录的唯一票据,第三方应用用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态
expires_in access_token的生命周期,单位是秒数。
token_type access_token的类型
refresh_token 刷新令牌,用于刷新access_token
刷新访问令牌(Refresh token)

根据用户ID、密钥、refresh_token进行过期token的刷新操作,重新生成access_token,并恢复access_token的失效时间

接口地址(URI):/api/oauth2/refresh_token

HTTP请求方式:POST

请求参数:
请求值字段 必选 类型 说明
client_id true String API用户鉴权 id;申请API时分配的API Key
client_secret true String 申请API应用时分配的密钥
grant_type true String 请求的类型,统一填写:refresh_token
refresh_token true String 刷新令牌,用于刷新access_token
请求参数示例example value:
Curl:curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'client_id=aaa&client_secret=bbb&grant_type=refresh_token&refresh_token=2469a4d9e788499c9a920becda82cd90' 'https://api.fotomore.com/api/oauth2/refresh_token'

Request URL:https://api.fotomore.com/api/oauth2/refresh_token

返回数据示例example value:
{
"refresh_token": "abd89df7dabf40206f92f560af491c3",
"token_type": "bearer",
"access_token": "e4b0a45238d2e5591eca9591c30f1dde98660dff1828b0104724da775aec943"
"expires_in": 7200,
}
返回值字段 字段说明
access_token 用户授权的唯一票据,用于调用接口,同时也是第三方应用验证用户登录的唯一票据,第三方应用用该票据和自己应用内的用户建立唯一影射关系,来识别登录状态
expires_in access_token的生命周期,单位是秒数。
token_type access_token的类型
refresh_token 刷新令牌,用于刷新access_token