Skip to main content

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.

itemdescription
HTTP MethodPOST
Request URIsandbox 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.

propertytitletyperequireddescription

idp

Identifier name of the cooperationstringtrue

Fixed value: "app"

id

InAppUserIdstringtrue

Specify the user ID (InAppUserId) linked to the player of the application.

Response Status​

The response status when succeeded is as follows.

statusdescription
200 OKWhen the resource can be returned normally.

Response Header​

Response header is as follows.

namevaluerequireddescription
Content-Typeapplication/jsontrue 

Response Body​

The JSON string with the following parameters is sent. Please refer to the example below for details.

propertytitletyperequireddescription

id

Player IDintegertrue

The player ID of this player.

links

IdP cooperation objectobjecttrue

An object that represents the type of the external Identity Provider that cooperates this player.

links.appInAppUser cooperation objectobjectfalseAn object which exists in the case that this player has the InAppUser ID.
links.app.idInAppUserIDstringtrueThe InAppUserId value that is set to the player (app-specific ID).
links.app.createdAtThe start date and time when the InAppUserId has been set.integertrueThe date and time when the User ID in the application (InAppUserId) has been set.
links.app.updatedAtThe date and time when the InAppUserId has been updated.integertrueThe date and time when the User ID in the application (InAppUserId) has been updated.
links.mobageMobage cooperation objectobjectfalse

An object which exists in the case that this player is connected to the Mobage.

links.mobage.createdAtThe start date and time when cooperatingintegertrue

The UNIX timestamp value when started to connect this player to the Mobage.

links.mobage.updatedAtThe update date and time when cooperatingintegertrue 
createdAtCreation date and timeintegertrue

The UNIX timestamp when this resource is created.

updatedAtDate Modifiedintegertrue

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.

statustitletypedescription
400Bad Requestabout:blankIt will be returned when a bad Player ID is specified in the URI Template parameters
404Not Foundabout:blankIt will be returned if a nonexistent Player ID is specified in the URI Template parameters
409Conflictabout: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.

422TARGET HAS ONCE LINKED MBGA

about:blank

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.

500Server Errorabout:blankThe error occurs on the API server.
503Service Unavailableabout:blankThe 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