> For the complete documentation index, see [llms.txt](https://wiki.playgama.com/playgama/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.playgama.com/playgama/bridge-sdk-v1/bridge-sdk/api/player.md).

# Player

Optional module for player identity, profile data and platform authorization.

## Authorization Support

Check this before showing a login button. Authorization support depends on the host platform.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.player.isAuthorizationSupported
```

{% endtab %}

{% tab title="Unity" %}

```java
// Possible values: true, false
Bridge.player.isAuthorizationSupported
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/1GumSRP2m6J6KKVgRyMK" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/dEhfbEclpwFb0d2XyZiQ" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.player.is_authorization_supported
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_player_is_authorization_supported()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.player.is_authorization_supported()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.player.isAuthorizationSupported
```

{% endtab %}
{% endtabs %}

<details>

<summary>Platform support · 17 of 28 platforms</summary>

**Supports:** `absolute_games`, `bitquest`, `crazy_games`, `discord`, `facebook`, `huawei`, `microsoft_store`, `msn`, `ok`, `playdeck`, `playgama`, `samsung`, `telegram`, `tiktok`, `vk`, `y8`, `yandex`

**Does not support:** `dlightek`, `game_distribution`, `gamepush`, `gamesnacks`, `jio_games`, `lagged`, `poki`, `portal`, `reddit`, `xiaomi`, `youtube`

</details>

## Is the Player Currently Authorized

Use this to decide whether protected features are available right now, such as account-based saves, personalized content, or social actions.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.player.isAuthorized
```

{% endtab %}

{% tab title="Unity" %}

```java
// Possible values: true, false
Bridge.player.isAuthorized
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/T9ZOOJEa1x6G5T32p7L3" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/92qzI7efBRC7g1W0utMH" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.player.is_authorized
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_player_is_authorized()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.player.is_authorized()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.player.isAuthorized
```

{% endtab %}
{% endtabs %}

## Player ID

Returns the player's platform ID when available. Use it for display, analytics correlation, or backend verification, but do not rely on it until authorization is confirmed.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.player.id
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.player.id
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlayerId
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlayerId()
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.player.id
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_player_id()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.player.id()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.player.id
```

{% endtab %}
{% endtabs %}

If the platform supports authorization and the player is currently authorized, this returns their platform ID. Otherwise, it returns `null`.

## Player Name

Returns the display name provided by the platform. Use it for profile UI, leaderboards, friend lists, or social prompts.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.player.name
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.player.name
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlayerName
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlayerName()
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.player.name
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_player_name()
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.player.name()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.player.name
```

{% endtab %}
{% endtabs %}

Returns `null` when no name is available; otherwise returns a string.

## Player Avatar

Returns available player avatar URLs. Use the largest suitable image for profile UI, lobbies, or leaderboard rows.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.player.photos
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.player.photos
```

{% endtab %}

{% tab title="Construct 3" %}
Number of Player Avatars:

```javascript
PlaygamaBridge.PlayerPhotosCount
```

Get Avatar by Index:

```javascript
PlaygamaBridge.PlayerPhoto(index)
```

{% endtab %}

{% tab title="GDevelop" %}
Number of Player Avatars:

```javascript
PlaygamaBridge::PlayerPhotosCount()
```

Get Avatar by Index:

```javascript
PlaygamaBridge::PlayerPhoto(<Number>)
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.player.photos
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
var photos = json_parse(playgama_bridge_player_photos())
```

{% endtab %}

{% tab title="Defold" %}

```lua
bridge.player.photos()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.player.photos
```

{% endtab %}
{% endtabs %}

Possible values: an array of avatar URLs sorted by increasing resolution, or an empty array.

## Player Extra Fields

Returns platform-specific authorization data. Properties vary by platform.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
bridge.player.extra
```

{% endtab %}

{% tab title="Unity" %}

```java
Bridge.player.extra
```

{% endtab %}

{% tab title="Construct 3" %}

```javascript
PlaygamaBridge.PlayerExtraPropertyCount
```

```javascript
PlaygamaBridge.PlayerExtraPropertyName(<extra_prop_index>)
```

```javascript
PlaygamaBridge.PlayerExtraPropertyValue("<extra_prop>")
```

{% endtab %}

{% tab title="GDevelop" %}

```javascript
PlaygamaBridge::PlayerExtraPropertyCount()
```

```javascript
PlaygamaBridge::PlayerExtraPropertyName(<extra_prop_index>)
```

```javascript
PlaygamaBridge::PlayerExtraPropertyValue("<extra_prop>")
```

{% endtab %}

{% tab title="Godot" %}

```gdscript
Bridge.player.extra
```

{% endtab %}

{% tab title="GameMaker" %}

```javascript
playgama_bridge_player_extra()
```

{% endtab %}

{% tab title="Defold" %}

```javascript
bridge.player.extra()
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
bridge.player.extra
```

{% endtab %}
{% endtabs %}

Use this data on your backend to verify authorization. Playgama API verification currently supports only `playgama`, `msn`, and `microsoft_store`.

```bash
curl -X POST "https://playgama.com/api/bridge/v1/verify" \
  -H "Content-Type: application/json" \
  -d '{"platform":"<PLATFORM_ID>","type":"authorization","data":{  <...bridge.player.extra> }}'
  
#  Response:
#  {
#    success: boolean;
#    errorMessage?: string;

#    -- authorization --
#    playerId?: string;
#    publisherPlayerId?: string;
#  }
```

## Player Authorization

Start the platform authorization flow. Call this from a direct player action, such as tapping a login button, before enabling account-only features.

{% tabs %}
{% tab title="Plain JS" %}

```javascript
// optional parameter
let options = { }

bridge.player.authorize(options)
    .then(() => {
        // player successfully authorized
    })
    .catch(error => {
        // error, something went wrong
    })
```

{% endtab %}

{% tab title="Unity" %}

```csharp
private void Start()
{
    var options = new Dictionary<string, object>();

    Bridge.player.Authorize(options, OnAuthorizePlayerCompleted);
}

private void OnAuthorizePlayerCompleted(bool success)
{
    if (success)
    {
        // Player successfully authorized
    }
    else
    {
        // Error, something went wrong
    }
}
```

{% endtab %}

{% tab title="Construct 3" %}

<figure><img src="/files/ejCPL5L7ydioWoN0hqeG" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-clicked","objectClass":"Button"}],"actions":[{"id":"authorize-player","objectClass":"PlaygamaBridge"}]},{"eventType":"block","conditions":[{"id":"on-authorize-player-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge"}],"actions":[{"type":"comment","text":"success"}]},{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge","isInverted":true}],"actions":[{"type":"comment","text":"error"}]}]}]}
```

</details>
{% endtab %}

{% tab title="GDevelop" %}

<figure><img src="/files/yKPTKYfaFoQu5i8a5jax" alt=""><figcaption></figcaption></figure>

<details>

<summary>Copy This Example</summary>

```
{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::AuthorizePlayer"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnAuthorizePlayerCompleted"},"parameters":["",""]}],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"success\"","\"info\"",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"inverted":true,"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"error\"","\"info\"",""]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}
```

</details>
{% endtab %}

{% tab title="Godot" %}
{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _ready():
    var options = {}

    Bridge.player.authorize(options, funcref(self, "_on_player_authorize_completed"))

func _on_player_authorize_completed(success):
    if success:
        print("Authorized")
    else:
        print("Authorization error")
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _ready():
    var options = {}

    Bridge.player.authorize(options, Callable(self, "_on_player_authorize_completed"))

func _on_player_authorize_completed(success):
    if success:
        print("Authorized")
    else:
        print("Authorization error")
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="GameMaker" %}

```gml
var options = { }

playgama_bridge_player_authorize(json_stringify(options))

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_player_authorize_callback" {
    if async_load[? "success"] {
        // your logic
    }
}
```

{% endtab %}

{% tab title="Defold" %}

```lua
local bridge = require("bridge.bridge")

function init(self)
	local options = {}

	bridge.player.authorize(
		options, 
		function ()
			-- success
		end, 
		function ()
			-- error
		end)
end
```

{% endtab %}

{% tab title="Cocos Creator" %}

```javascript
async authorize() {
    const options: Record<string, any> = {};
    
    try {
        await bridge.player.authorize(options);
        // player successfully authorized
    } catch (error) {
        // error, something went wrong
    }
}
```

{% endtab %}
{% endtabs %}
