> ## 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.

# XUserGetTokenAndSignatureData

> XUserGetTokenAndSignatureData

# XUserGetTokenAndSignatureData

Spécifie les xtokens et les signatures que nous récupérons pour les requêtes web.

## Syntaxe

```cpp theme={null}
typedef struct XUserGetTokenAndSignatureData {  
    size_t tokenSize;  
    size_t signatureSize;  
    const char* token;  
    const char* signature;  
} XUserGetTokenAndSignatureData  
```

### Membres

*tokenSize*\
Type : size\_t

La taille en octets de la mémoire tampon dans la propriété **token**.

*signatureSize*\
Type : size\_t

La taille en octets de la mémoire tampon dans la propriété **signature**.

*token*\
Type : const char\*

Une mémoire tampon qui contient le jeton récupéré.

*signature*\
Type : const char\*

Une mémoire tampon qui contient la signature récupérée.

## Remarques

Pour récupérer le résultat d'un appel à [XUserGetTokenAndSignatureAsync](/fr-CA/reference/system/xuser/functions/xusergettokenandsignatureasync), appelez la fonction [XUserGetTokenAndSignatureResult](/fr-CA/reference/system/xuser/functions/xusergettokenandsignatureresult).

La fonction [XUserGetTokenAndSignatureAsync](/fr-CA/reference/system/xuser/functions/xusergettokenandsignatureasync) récupère de façon asynchrone des xtokens et des signatures pour les requêtes web.

La fonction [XUserGetTokenAndSignatureResult](/fr-CA/reference/system/xuser/functions/xusergettokenandsignatureresult) utilise un double pointeur vers une structure XUserGetTokenAndSignatureData comme argument.

L'exemple suivant montre comment récupérer de façon asynchrone le jeton et la signature d'un utilisateur.

```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;
}
```

## Configuration requise

**En-tête :** XUser.h

**Plateformes prises en charge :** Windows, consoles de la famille XBOX One et consoles XBOX Series

## Voir aussi

[XUser](/fr-CA/reference/system/xuser/xuser_members)

[XUserGetTokenAndSignatureAsync](/fr-CA/reference/system/xuser/functions/xusergettokenandsignatureasync)

[XUserGetTokenAndSignatureResult](/fr-CA/reference/system/xuser/functions/xusergettokenandsignatureresult)


## Related topics

- [XUserGetTokenAndSignatureData](/reference/system/xuser/structs/xusergettokenandsignaturedata.md)
- [XUserGetTokenAndSignatureResult](/reference/system/xuser/functions/xusergettokenandsignatureresult.md)
- [XUser](/reference/system/xuser/xuser_members.md)
