Player Link API
Overview
This API allows you to save the user ID (InAppUserId) linked to the player of the application.
How to Authorize
To use this API, an access token which retrieve by the grant_type and scope described on the following table must be specified on the Authorization request header.
- Authorization Type
- Bearer
- Supported grant_type
- client_credentials_grant
- The necessary scope
- player.links:authorizedUsers:write
Endpoint URL
The endpoint URL in each environment will be following.
| item | description |
|---|---|
| HTTP Method | POST |
| Request URI | sandbox java https://sb-api.andapp.jp/1.0.0/users{/playerId}/link production java https://api.andapp.jp/1.0.0/users{/playerId}/link |
Request Example
Request example is as follows.
POST /1.0.0/users/4503599627370495/link HTTP/1.1
Host: sb-api.andapp.jp:443
Authorization: Bearer {access_token}
Content-Type: application/x-www-form-urlencoded
idp=app&id=12345
Request Body
You can set the request parameters with the following parameters.
| property | title | type | required | description |
|---|---|---|---|---|
idp | Identifier name of the cooperation | string | true | Fixed value: "app" |
id | InAppUserId | string | true | Specify the user ID (InAppUserId) linked to the player of the application. |
Response Status
The response status when succeeded is as follows.
| status | description |
|---|---|
| 200 OK | When the resource can be returned normally. |
Response Header
Response header is as follows.
| name | value | required | description |
|---|---|---|---|
| Content-Type | application/json | true |
Response Body
The JSON string with the following parameters is sent. Please refer to the example below for details.
| property | title | type | required | description |
|---|---|---|---|---|
id | Player ID | integer | true | The player ID of this player. |
links | IdP cooperation object | object | true | An object that represents the type of the external Identity Provider that cooperates this player. |
| links.app | InAppUser cooperation object | object | false | An object which exists in the case that this player has the InAppUser ID. |
| links.app.id | InAppUserID | string | true | The InAppUserId value that is set to the player (app-specific ID). |
| links.app.createdAt | The start date and time when the InAppUserId has been set. | integer | true | The date and time when the User ID in the application (InAppUserId) has been set. |
| links.app.updatedAt | The date and time when the InAppUserId has been updated. | integer | true | The date and time when the User ID in the application (InAppUserId) has been updated. |
| links.mobage | Mobage cooperation object | object | false | An object which exists in the case that this player is connected to the Mobage. |
| links.mobage.createdAt | The start date and time when cooperating | integer | true | The UNIX timestamp value when started to connect this player to the Mobage. |
| links.mobage.updatedAt | The update date and time when cooperating | integer | true | |
| createdAt | Creation date and time | integer | true | The UNIX timestamp when this resource is created. |
| updatedAt | Date Modified | integer | true | The UNIX timestamp when this resource is updated. |
Response Example (In case that the IdP has already been cooperated)
HTTP/1.1 200 OK
Content-Type: application/json
{
"createdAt": 1485255409,
"id": 4503599627370495,
"links": {
"app": {
"createdAt": 1485497186,
"id": "12345",
"updatedAt": 1485502361
},
"mobage": {
"createdAt": 1439726867,
"updatedAt": 1439726867
}
},
"updatedAt": 1485502361
}
Response Example (In case that the IdP is not cooperated yet)
HTTP/1.1 200 OK
Content-Type: application/json
{
"createdAt": 1485255409,
"id": 4503599627370495,
"links": {
"app": {
"createdAt": 1485497186,
"id": "12345",
"updatedAt": 1485502361
}
},
"updatedAt": 1485502361
}
Error Response
Error response will be returned in the application/problem+json format. The status code and the value of the type property of Problem Type is as follows.
| status | title | type | description |
|---|---|---|---|
| 400 | Bad Request | about:blank | It will be returned when a bad Player ID is specified in the URI Template parameters |
| 404 | Not Found | about:blank | It will be returned if a nonexistent Player ID is specified in the URI Template parameters |
| 409 | Conflict | about:blank | It will be retuned when the specified User ID in the application (InAppUserId) has already been linked to the other AndApp user who has already been cooperated to the Mobage. This error must be handled, and encourage to link to other InAppUserID or to start a new play. |
| 422 | TARGET HAS ONCE LINKED MBGA | It will be returned when the specified user ID in the application (InAppUserId) has already been linked to the the player ID cooperated to the IdP. | |
| 500 | Server Error | about:blank | The error occurs on the API server. |
| 503 | Service Unavailable | about:blank | The API server can't answer temporary. |
Error Response Example
The example of an error response is as follows.
When it was non-existent Player ID
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
{
"type": "about:blank",
"title": "Not Found",
"code": 404,
"instance": "https://sb-api.andapp.jp/1.0.0/users/4503599627370495/link"
}
When the specified user ID in the application (InAppUserId) has already been linked to other AndApp user cooperated to the Mobage
HTTP/1.1 409 Conflict
Content-Type: application/problem+json
{
"type": "https://problems.andapp.jp/1.0.0/common/409/conflict",
"title": "Conflict",
"status": 409,
"detail": "cannot process request with the link object because it has been locked by an other player",
"instance": "https://sb-api.andapp.jp//1.0.0/users/5392399203303424/link"
}
When the specified user ID in the application (InAppUserId) has already been linked to other player ID cooperated to the IdP
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json
{
"type": "https://problems.andapp.jp/1.0.0/users/422/target_has_once_linked_mbga",
"title": "TARGET HAS ONCE LINKED MBGA",
"status": 422,
"detail": "target has once linked mbga",
"instance": "https://sb-api.andapp.jp//1.0.0/users/5392399203303424/link"
}
Change log
- 2017/07/04
- Corrected some sentences where should write as 422
- 2017/03/15
- Modified by the behavior change of the Player Link API
- 2017/02/15
- Created