Iniciar sesión con id. personalizado de servidor
Securely login a game client from an external server backend using a custom identifier for that player. Server Custom ID and Client Custom ID are mutually exclusive and cannot be used to retrieve the same player account.
Error codes
This operation may return the following PlayFab errors:
| Error | Code |
|---|---|
| EvaluationModePlayerCountExceeded | 1490 |
curl --request POST \
--url https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId \
--header 'Content-Type: application/json' \
--header 'X-SecretKey: <api-key>' \
--data '
{
"ServerCustomId": "asdalsdkjar09u23ijf",
"CreateAccount": true
}
'import requests
url = "https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId"
payload = {
"ServerCustomId": "asdalsdkjar09u23ijf",
"CreateAccount": True
}
headers = {
"X-SecretKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SecretKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ServerCustomId: 'asdalsdkjar09u23ijf', CreateAccount: true})
};
fetch('https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ServerCustomId' => 'asdalsdkjar09u23ijf',
'CreateAccount' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SecretKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId"
payload := strings.NewReader("{\n \"ServerCustomId\": \"asdalsdkjar09u23ijf\",\n \"CreateAccount\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SecretKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId")
.header("X-SecretKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ServerCustomId\": \"asdalsdkjar09u23ijf\",\n \"CreateAccount\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SecretKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ServerCustomId\": \"asdalsdkjar09u23ijf\",\n \"CreateAccount\": true\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"status": "<string>",
"data": {
"NewlyCreated": true,
"EntityToken": {
"EntityToken": "lS2hbYH1Gls1KbnlyozHSQBrF4zsq6q006ci9ijSNqQUiiO6xyCQtVrLjsXjdBJ",
"TokenExpiration": "2022-01-26T07:24:12Z",
"Entity": {
"Id": "174812abf712",
"Type": "title_player_account",
"TypeString": "title_player_account"
}
},
"InfoResultPayload": {
"AccountInfo": {
"PlayFabId": "4027527BF22653D1",
"Created": "2013-04-07T09:04:28",
"Username": "my name",
"TitleInfo": {
"Origination": "IOS",
"Created": "2014-01-08T11:03:18",
"LastLogin": "2014-04-07T09:04:28",
"FirstLogin": "2014-01-08T11:03:18",
"TitlePlayerAccount": {
"Id": "174812abf712",
"Type": "title_player_account",
"TypeString": "title_player_account"
}
},
"FacebookInfo": {
"FacebookId": "23525445454"
},
"SteamInfo": {
"SteamCountry": "US",
"SteamCurrency": "USD"
},
"GameCenterInfo": {
"GameCenterId": "someone"
}
},
"UserVirtualCurrency": {
"GC": 15
},
"UserVirtualCurrencyRechargeTimes": {
"GC": {
"SecondsToRecharge": 3600,
"RechargeTime": "2014-01-01T12:00:00",
"RechargeMax": 50
}
},
"UserData": {
"preferences": {
"Value": "alpha",
"LastUpdated": "2014-08-20T12:30:45",
"Permission": "Public"
},
"progress": {
"Value": "level_twenty",
"LastUpdated": "2014-09-01T10:12:30"
}
},
"UserDataVersion": 12,
"PlayerProfile": {
"TitleId": "TitleName",
"PlayerId": "10931252888739651331",
"Created": "0001-01-01T00:00:00",
"LastLogin": "0001-01-01T00:00:00",
"BannedUntil": "9999-12-31T23:59:59.9999999",
"DisplayName": "PlayerDisplayName",
"TotalValueToDateInUSD": 0
}
},
"LastLoginTime": "<string>",
"PlayFabId": "<string>",
"SessionTicket": "<string>",
"SettingsForUser": {
"GatherDeviceInfo": true,
"GatherFocusInfo": true,
"NeedsAttribution": true
},
"TreatmentAssignment": {
"Variables": [
{
"Name": "<string>",
"Value": "<string>"
}
],
"Variants": [
"<string>"
]
}
}
}{
"code": 123,
"errorCode": 123,
"status": "<string>",
"error": "<string>",
"errorMessage": "<string>",
"errorDetails": {}
}Autorizaciones
This API requires a title secret key, available to title admins, from PlayFab Game Manager.
Cuerpo
The backend server identifier for this player.
Automatically create a PlayFab account if one is not currently linked to this ID.
The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
Flags for which pieces of info to return for the user.
Show child attributes
Show child attributes
{
"GetUserAccountInfo": true,
"GetUserVirtualCurrency": true,
"GetUserData": true,
"UserDataKeys": ["preferences", "progress"]
}
Player secret that is used to verify API request signatures.
Temas relacionados
Iniciar sesión con id. personalizadoIniciar sesión con id. de XboxIniciar sesión con id. de SteamIniciar sesión con id. de dispositivo AndroidIniciar sesión con id. de dispositivo iOS¿Esta página le ayudó?
curl --request POST \
--url https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId \
--header 'Content-Type: application/json' \
--header 'X-SecretKey: <api-key>' \
--data '
{
"ServerCustomId": "asdalsdkjar09u23ijf",
"CreateAccount": true
}
'import requests
url = "https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId"
payload = {
"ServerCustomId": "asdalsdkjar09u23ijf",
"CreateAccount": True
}
headers = {
"X-SecretKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SecretKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({ServerCustomId: 'asdalsdkjar09u23ijf', CreateAccount: true})
};
fetch('https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ServerCustomId' => 'asdalsdkjar09u23ijf',
'CreateAccount' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SecretKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId"
payload := strings.NewReader("{\n \"ServerCustomId\": \"asdalsdkjar09u23ijf\",\n \"CreateAccount\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SecretKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId")
.header("X-SecretKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"ServerCustomId\": \"asdalsdkjar09u23ijf\",\n \"CreateAccount\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{titleId}.playfabapi.com/Server/LoginWithServerCustomId")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SecretKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ServerCustomId\": \"asdalsdkjar09u23ijf\",\n \"CreateAccount\": true\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"status": "<string>",
"data": {
"NewlyCreated": true,
"EntityToken": {
"EntityToken": "lS2hbYH1Gls1KbnlyozHSQBrF4zsq6q006ci9ijSNqQUiiO6xyCQtVrLjsXjdBJ",
"TokenExpiration": "2022-01-26T07:24:12Z",
"Entity": {
"Id": "174812abf712",
"Type": "title_player_account",
"TypeString": "title_player_account"
}
},
"InfoResultPayload": {
"AccountInfo": {
"PlayFabId": "4027527BF22653D1",
"Created": "2013-04-07T09:04:28",
"Username": "my name",
"TitleInfo": {
"Origination": "IOS",
"Created": "2014-01-08T11:03:18",
"LastLogin": "2014-04-07T09:04:28",
"FirstLogin": "2014-01-08T11:03:18",
"TitlePlayerAccount": {
"Id": "174812abf712",
"Type": "title_player_account",
"TypeString": "title_player_account"
}
},
"FacebookInfo": {
"FacebookId": "23525445454"
},
"SteamInfo": {
"SteamCountry": "US",
"SteamCurrency": "USD"
},
"GameCenterInfo": {
"GameCenterId": "someone"
}
},
"UserVirtualCurrency": {
"GC": 15
},
"UserVirtualCurrencyRechargeTimes": {
"GC": {
"SecondsToRecharge": 3600,
"RechargeTime": "2014-01-01T12:00:00",
"RechargeMax": 50
}
},
"UserData": {
"preferences": {
"Value": "alpha",
"LastUpdated": "2014-08-20T12:30:45",
"Permission": "Public"
},
"progress": {
"Value": "level_twenty",
"LastUpdated": "2014-09-01T10:12:30"
}
},
"UserDataVersion": 12,
"PlayerProfile": {
"TitleId": "TitleName",
"PlayerId": "10931252888739651331",
"Created": "0001-01-01T00:00:00",
"LastLogin": "0001-01-01T00:00:00",
"BannedUntil": "9999-12-31T23:59:59.9999999",
"DisplayName": "PlayerDisplayName",
"TotalValueToDateInUSD": 0
}
},
"LastLoginTime": "<string>",
"PlayFabId": "<string>",
"SessionTicket": "<string>",
"SettingsForUser": {
"GatherDeviceInfo": true,
"GatherFocusInfo": true,
"NeedsAttribution": true
},
"TreatmentAssignment": {
"Variables": [
{
"Name": "<string>",
"Value": "<string>"
}
],
"Variants": [
"<string>"
]
}
}
}{
"code": 123,
"errorCode": 123,
"status": "<string>",
"error": "<string>",
"errorMessage": "<string>",
"errorDetails": {}
}