# 生成用户鉴权token

## Authorize

> 该API接口由**OMG平台**提供,由**接入方**进行调用

<mark style="color:green;">`POST`</mark>  `{OMG_API_URL}/api/player/v1/authorize?trace_id=your_trace_id`

{% hint style="info" %}
`{OMG_API_URL}`为OMG接口域名,可通过后台获得
{% endhint %}

### **Headers**

<table><thead><tr><th width="263">Name</th><th>Value</th></tr></thead><tbody><tr><td><code>Content-Type</code></td><td>"application/json; charset=utf-8"</td></tr><tr><td><code>sign</code></td><td>"your_sign_string"</td></tr></tbody></table>

{% hint style="info" %}
签名算法请查阅 [签名算法及示例](https://docs.omgapi.cc/kuai-su-kai-shi/quickstart#qian-ming-suan-fa-ji-shi-li) 页面描述
{% endhint %}

### **Body**

<table><thead><tr><th width="172">Name</th><th width="211">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>app_id</code></td><td>string</td><td><p>商户的唯一标识</p><p>可通过商户后台获得</p></td></tr><tr><td><code>uname</code></td><td>string</td><td>用户的id 必须唯一</td></tr><tr><td><code>nickname</code></td><td>string</td><td>用户昵称 最长40个字节</td></tr><tr><td><code>timestamp</code></td><td>integer</td><td>时间戳(秒)</td></tr><tr><td><code>cid</code></td><td>integer <code>非必填</code></td><td>货币id,<code>多货币商户</code>必传,可以在总代后台<code>API接入>多货币</code> 查看已开通的货币id</td></tr></tbody></table>

### **接入方请求参数示例**&#x20;

```json
{
    "app_id":"10013",
    "nickname": "Bill",
    "uname": "10032355",
    "cid":0
}
```

### OMG平台响应参数示例

{% tabs %}
{% tab title="成功" %}

```json
{
    "code": 0,
    "msg": "ok",
    "data": {
        "token": "1003803",
        "balance": "42766.25",
        "app_id":10013
    }
}
```

{% endtab %}

{% tab title="失败" %}

```json
{
    "code": 10002,
    "msg": "sign invalid"
}
```

{% endtab %}
{% endtabs %}

### **成功返回示例的参数说明**

<table><thead><tr><th width="135">参数名</th><th width="122">必选</th><th width="159">类型</th><th>说明</th></tr></thead><tbody><tr><td>code</td><td>是</td><td>integer</td><td>状态码</td></tr><tr><td>msg</td><td>是</td><td>string</td><td>提示信息</td></tr><tr><td>data</td><td>是</td><td>object</td><td>返回的数据</td></tr><tr><td>token</td><td>是</td><td>string</td><td><a data-footnote-ref href="#user-content-fn-1">玩家在OMG平台的token</a></td></tr><tr><td>balance</td><td>是</td><td>string (decimal)</td><td>用户余额 (最多支持4位小数)</td></tr><tr><td>app_id</td><td>是</td><td>string</td><td><a data-footnote-ref href="#user-content-fn-2">玩家归属商户的app_id</a></td></tr></tbody></table>

### 错误码

{% hint style="info" %}
更多返回错误代码请查阅 [通用错误码 ](https://docs.omgapi.cc/kuai-su-kai-shi/tong-yong-cuo-wu-ma)页面描述
{% endhint %}

[^1]: 后续操作这个玩家的数据都需要带上这个token，例如:查询玩家余额，给玩家充值等

[^2]: 如果请求参数的app\_id是多货币商户,会返回请求参数cid一致的多货币商户的子商户的app\_id,否则返回请求参数的app\_id的值


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.omgapi.cc/you-xi-api-jie-kou/zhuan-zhang-qian-bao/sheng-cheng-yong-hu-jian-quan-token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
