API   ->   Token

获取xAuthToken


令牌(token)是调用所有API都需要传递的凭证信息。若想调用API需要携带应用信息和用户信息到指定的端点申请令牌。 这就意味着一个令牌对应一个应用信息和一个用户信息。若想使用若干不同用户的身份调用API,则需要针对每一个用户申请一次令牌。

获取token是调用开放平台API接口的第一步,几乎所有的业务API接口都需要依赖于token来确定调用方(应用,app)和用户(user)身份。

请求示例:

https://app.redbeandata.cn/cubedrive/getLogin

参数:

http方法: GET/POST

开发者需要缓存x-auth-token,用于后续接口的调用(注意:不能频繁调用此接口,否则会受到频率拦截)。当x-auth-token失效或过期时,需要重新获取。 由于运营策略,不保证token在有效期内持续有效。开发者应实现access_token失效时重新获取的逻辑。 x-auth-token至少保留256字节的存储空间。

返回示例

{
	"success":true,
	"systemInfo":{
		"logoPath":"https://app.redbeandata.cn/cubedrive/images/customer/REDBEANDATA.png",
		"language":"zh_CN",
		"systemName":"REDBEANDATA",
		"systemDesc":"企事业数字化转型的私有云方案",
		"showAppModule":true,
		"showHelpModule":true,
		"canSelfRegister":true
	},
	"userLang":"zh_CN",
	"userObj":{
		"id":"14r7AYizW6c",
		"firstname":"管理员",
		"lastname":"张",
		"name":"张/管理员",
		"imagepath":"https://app.redbeandata.cn/cubedrive/userFile/redbeandata/users/user22/profile/thumb_people-1586059479881.png",
		"description":null,
		"username":"xxxxx",
		"email":"xxxx@cubedrive.com",
		"enabled":null,
		"role":"user",
		"roleId":2,
		"createDate":null,
		"maxApp":null,
		"maxShared":null,
		"maxRecords":null,
		"maxSpace":null
	},
	"x-auth-token": "32997522-0c9f-4336-80fb-fef717e28248"
}
    

使用token


获取到token后,就能使用平台提供的API了。在调用API时,只需要添加如下所示的Authorization请求头(Headers)即可。

X-Auth-Token: {{xAuthToken}}
请将{{xAuthToken}}替换为之前已获取的x-auth-token内容。

用户也可以把Token做为参数传入:

https://app.redbeandata.cn/cubedrive/commonPage?page=formData&x-auth-token={{xAuthToken}}


验证token


用户可以通过这个接口 来查询 x-auth-token 是否有效。

https://app.redbeandata.cn/cubedrive/verifyAuthToken?authToken=9e2373f7-b3de-4ad4-9606-59b8c9cb70b6
如果有效,就会返回如下结果。
{"success":true,"valid":true}