> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XUserGetTokenAndSignatureResultSize

> XUserGetTokenAndSignatureResultSize

# XUserGetTokenAndSignatureResultSize

[XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync) の呼び出し結果を保持するためのバッファー サイズを取得します。

## 構文

```cpp theme={null}
HRESULT XUserGetTokenAndSignatureResultSize(  
         XAsyncBlock* async,  
         size_t* bufferSize  
)  
```

### パラメーター

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

呼び出しの状態のポーリングと呼び出し結果の取得に使用する [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) です。

*bufferSize*   \_Out\_\
Type: size\_t\*

必要なバッファー サイズが格納されます。

### 戻り値

Type: HRESULT

成功した場合は S\_OK を返します。それ以外の場合はエラー コードを返します。
エラー コードの一覧については、[エラー コード](/reference/errorcodes) を参照してください。

## 解説

Web 要求用の xtoken と署名を非同期に取得するには、[XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync) を呼び出します。

[XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync) の呼び出し結果を取得するには、[XUserGetTokenAndSignatureResult](/reference/system/xuser/functions/xusergettokenandsignatureresult) を呼び出します。

以下の例は、ユーザーのトークンと署名を非同期に取得する方法を示しています。

```cpp theme={null}
HRESULT RequestTokenComplete(XAsyncBlock* abResult)
{
    size_t bufferSize;
    RETURN_IF_FAILED(XUserGetTokenAndSignatureResultSize(abResult, &bufferSize));

    std::vector<uint8_t> buffer(bufferSize);
    XUserGetTokenAndSignatureData* data;
    if (SUCCEEDED_LOG(XUserGetTokenAndSignatureResult(abResult, buffer.size(), buffer.data(), &data, nullptr /*bufferUsed*/)))
    {
        appLog.AddLog("Token: %s\n", data->token);
        if (data->signature != nullptr)
        {    
            appLog.AddLog("Signature: %s\n", data->signature);
        }
    }

    return S_OK;
}

HRESULT RequestTokenAsync(
    XTaskQueueHandle queue,
    const char* url,
    bool forceRefresh)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = queue;
    asyncBlock->context = this;
    asyncBlock->callback = [](XAsyncBlock* ab)
    {
        LOG_IF_FAILED(static_cast<User*>(ab->context)->RequestTokenComplete(ab));
        delete ab;
    };


    XUserGetTokenAndSignatureOptions options = XUserGetTokenAndSignatureOptions::None;

    if (forceRefresh)
    {
        WI_SET_FLAG(options, XUserGetTokenAndSignatureOptions::ForceRefresh);
    }

    static const XUserGetTokenAndSignatureHttpHeader headers[] =
    {
        { "Accept", "application/json"},
        { "Why", "Because"},
    };

    if (SUCCEEDED_LOG(XUserGetTokenAndSignatureAsync(
        _handle.get(),
        options,
        "GET",
        url,
        ARRAYSIZE(headers),
        headers,
        0,
        nullptr,
        asyncBlock.get())))
    {
        // The call succeeded, so release the std::unique_ptr ownership of XAsyncBlock* since the callback will take over ownership.
        // If the call fails, the std::unique_ptr will keep ownership and delete the XAsyncBlock*
        asyncBlock.release();
    }

    return S_OK;
}
```

## 要件

**ヘッダー:** XUser.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、Steam Deck、XBOX One ファミリ本体および XBOX Series 本体

## 関連項目

[XUser](/reference/system/xuser/xuser_members)

[XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync)

[XUserGetTokenAndSignatureResult](/reference/system/xuser/functions/xusergettokenandsignatureresult)


## Related topics

- [XUserGetTokenAndSignatureResult](/ja-jp/reference/system/xuser/functions/xusergettokenandsignatureresult.md)
- [XUserGetTokenAndSignatureAsync](/ja-jp/reference/system/xuser/functions/xusergettokenandsignatureasync.md)
- [XUser](/ja-jp/reference/system/xuser/xuser_members.md)
- [GDK 向け Unity C# API ラッパー](/ja-jp/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XUserGetTokenAndSignatureUtf16ResultSize](/ja-jp/reference/system/xuser/functions/xusergettokenandsignatureutf16resultsize.md)
