RESTful API 流程概述
Endpoint for OAuth v1.0 API
Mobage Simplified Chinese Platform
| Environment | URL |
|---|---|
| Production Auth | http://sp.mobage-platform.cn/social/api/oauth/v2.01 |
| Sandbox Auth | http://sp.sb.mobage-platform.cn/social/api/oauth/v2.01 |
Mobage Traditional Chinese Platform
| Environment | URL |
|---|---|
| Production Auth | http://sp.mobage-platform.tw/social/api/oauth/v2.01 |
| Sandbox Auth | http://sp.sb.mobage-platform.tw/social/api/oauth/v2.01 |
Endpoint for Social API
Note: Social API includes Appdata API, Blacklist API, People API, Profanity API, Leaderboard API, Remote Notification API.
Mobage Simplified Chinese Platform
| Production Social | http://sp.mobage-platform.cn/social/api/restful/v2 |
| Sandbox Social | http://sp.sb.mobage-platform.cn/social/api/restful/v2 |
| Environment | URL |
| --- | --- |
Mobage Traditional Chinese Platform
| Environment | URL |
|---|---|
| Production Social | http://sp.mobage-platform.tw/social/api/restful/v2 |
| Sandbox Social | http://sp.sb.mobage-platform.tw/social/api/restful/v2 |
Endpoint for Bank API
Mobage Simplified Chinese Platform
| Production Bank | http://sp.mobage-platform.cn/social/api/restful/v2.02 |
| Sandbox Bank | http://sp.sb.mobage-platform.cn/social/api/restful/v2.02 |
| Environment | URL |
| --- | --- |
Mobage Traditional Chinese Platform
| Environment | URL |
|---|---|
| Production Bank | http://sp.mobage-platform.tw/social/api/restful/v2.02 |
| Sandbox Bank | http://sp.sb.mobage-platform.tw/social/api/restful/v2.02 |
RESTful API 将会在平台和合作伙伴之间被使用到。
请使用 OAuth 1.0 的步骤来利用 RESTful API
更详细的信息请阅读 RFC5849 - The OAuth 1.0 Protocol

获取临时凭据(temporary credentials)
1.利用XHR从游戏客户端向游戏服务器发出要求让游戏服务器向平台服务器请求临时凭据。
2.利用RESTful API 请求从游戏服务器到平台的临时凭据。
a) 签名用的consumer_key 以及 consumer_secret 可以在开发者门户的应用程序详细画面中取得。
b) 请将oauth_callback指定到"oob"。 http://tools.ietf.org/html/rfc5849#section-2.1
- 平台返回临时凭据到游戏服务器。
a) 已取得的临时凭据将会被使用到,请务必保存在游戏服务器中。
- 游戏服务器返回临时凭据到游戏客户端。
资源所有者认证
-
游戏客户端识别临时凭据,并且执行Social.Common.Auth.authorizeToken() 。
-
SDK将自动向平台要求认证。
-
平台返回认证码给SDK。
-
认证码作为参数返回给Social.Common.Auth.authorizeToken()的回调函数(callback)。
申请令牌凭据(Token Credential)
- 利用XHR从游戏客户端向游戏服务器发出要求让游戏服务器向平台服务器请求令牌凭据。
a) 这时,临时凭据的识别号和验证码将会被使用到。
b) 如果你没有使用HTTPS,请不要发送临时凭据的共享密匙到网络上。
-
利用RESTful API 请求从游戏服务器到平台的令牌凭据。
-
平台返回令牌凭据到游戏服务器。
a) 令牌凭据是有有效期限的。如果超过期限请重新从临时凭据开始取得。
- 游戏服务器给游戏客户端发出响应告知处理结束。
a) 这里请不要返回已取得的令牌凭据。
b) 例如,你可以返回由游戏服务器临时生成的session ID 以用于游戏客户端和游戏服务器之间的交互。
游戏服务器和平台之间通信
- 从游戏服务器发出RESTful API 请求到平台。
a) 请使用从开发者网站中获取的Consumer key / secret 以及前面获取的令牌凭据来签名。
- 平台会对游戏服务器作出响应。
游戏客户端和游戏服务器之间通信(参考示例)
- 游戏客户端使用XHR向游戏服务器发出请求。
a) 用户认证部分可以参考使用第12步的session。
- 游戏服务器对游戏客户端做出响应。