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

# XUserGetTokenAndSignatureOptions

> XUserGetTokenAndSignatureOptions

# XUserGetTokenAndSignatureOptions

Options pour [XUserGetTokenAndSignatureAsync](/fr/reference/system/xuser/functions/xusergettokenandsignatureasync).

## Syntaxe

```cpp theme={null}
enum class XUserGetTokenAndSignatureOptions  : uint32_t  
{  
    None = 0x00,  
    ForceRefresh = 0x01,  
    AllUsers = 0x02,  
}  
```

## Constantes

| Constante | Description |
| - | - |
| None | Aucune option. |
| ForceRefresh | Force une actualisation. |
| AllUsers | Obtient les jetons et les signatures de tous les utilisateurs. |

## Remarques

La fonction [XUserGetTokenAndSignatureAsync](/fr/reference/system/xuser/functions/xusergettokenandsignatureasync) utilise un argument d'énumération XUserGetTokenAndSignatureOptions pour récupérer de façon asynchrone les xtokens et les signatures des requêtes web.

De même, la fonction [XUserGetTokenAndSignatureUtf16Async](/fr/reference/system/xuser/functions/xusergettokenandsignatureutf16async) utilise un argument d'énumération XUserGetTokenAndSignatureOptions pour récupérer de façon asynchrone les xtokens et les signatures Unicode des requêtes web.

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/reference/system/xuser/xuser_members)

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

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

[XUserGetTokenAndSignatureUtf16Async](/fr/reference/system/xuser/functions/xusergettokenandsignatureutf16async)


## Related topics

- [XUserGetTokenAndSignatureOptions](/reference/system/xuser/enums/xusergettokenandsignatureoptions.md)
- [XUserGetTokenAndSignatureUtf16Result](/reference/system/xuser/functions/xusergettokenandsignatureutf16result.md)
- [XUserGetTokenAndSignatureUtf16Async](/reference/system/xuser/functions/xusergettokenandsignatureutf16async.md)
- [XUserGetTokenAndSignatureUtf16ResultSize](/reference/system/xuser/functions/xusergettokenandsignatureutf16resultsize.md)
- [XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync.md)
