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

# XUserGetTokenAndSignatureAsync

> XUserGetTokenAndSignatureAsync

# XUserGetTokenAndSignatureAsync

대상 URL에 대한 HTTPS 호출을 승인하는 데 필요한 X-token 및 Signature를 비동기적으로 가져오는 API입니다. 타이틀의 [Partner Center의 Single Sign-on 페이지](/services/xbox-services/fundamentals/s2s-auth-calls/custom-service-config/single-sign-on/live-single-sign-on)에서 대상 URL에 연결된 Relying Party가 있는 경우 X-token 및 Signature를 반환합니다. 요청을 하기 전에 HTTPS 호출의 Authorization 및 Signature 헤더에 [API의 Results 버전](/reference/system/xuser/functions/xusergettokenandsignatureresult)에서 얻은 X-token 및 Signature 값을 추가합니다.

## 구문

```cpp theme={null}
HRESULT XUserGetTokenAndSignatureAsync(  
         XUserHandle user,  
         XUserGetTokenAndSignatureOptions options,  
         const char* method,  
         const char* url,  
         size_t headerCount,  
         const XUserGetTokenAndSignatureHttpHeader* headers,  
         size_t bodySize,  
         const void* bodyBuffer,  
         XAsyncBlock* async  
)  
```

### 매개변수

*user*   \_In\_\
형식: XUserHandle

웹 요청이 대상으로 하는 사용자에 대한 핸들입니다.

*options*   \_In\_\
형식: [XUserGetTokenAndSignatureOptions](/reference/system/xuser/enums/xusergettokenandsignatureoptions)

사용자 토큰 및 서명을 가져오기 위한 옵션입니다.

*method*   \_In\_z\_\
형식: char\*

웹 요청의 메서드 유형입니다.

*url*   \_In\_z\_\
형식: char\*

HTTPS 요청의 대상 URL입니다. HTTPS 요청에는 전체 URL 문자열을 사용합니다. URL을 축약하지 마십시오.

*headerCount*   \_In\_\
형식: size\_t

*headers* 매개변수의 헤더 수입니다.

*headers*   \_In\_reads\_opt\_(headerCount)\
형식: [XUserGetTokenAndSignatureHttpHeader\*](/reference/system/xuser/structs/xusergettokenandsignaturehttpheader)

웹 요청의 헤더입니다.

*bodySize*   \_In\_\
형식: size\_t

*bodyBuffer* 매개변수의 버퍼 크기입니다.

*bodyBuffer*   \_In\_reads\_bytes\_opt\_(bodySize)\
형식: void\*

웹 요청의 본문을 포함하는 버퍼입니다.

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

호출의 상태를 폴링하고 호출 결과를 가져오기 위한 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)입니다.

### 반환값

형식: HRESULT

성공하면 S\_OK를 반환하고, 그렇지 않으면 오류 코드를 반환합니다.
오류 코드 목록은 [Error Codes](/reference/errorcodes)를 참조하십시오.

## 설명

XUserGetTokenAndSignatureAsync 호출의 결과를 가져오려면 [XUserGetTokenAndSignatureResult](/reference/system/xuser/functions/xusergettokenandsignatureresult)를 호출합니다.

[XUserGetTokenAndSignatureAsync](/reference/system/xuser/functions/xusergettokenandsignatureasync) 호출의 결과를 담기 위해 필요한 버퍼 크기를 가져오려면 [XUserGetTokenAndSignatureResultSize](/reference/system/xuser/functions/xusergettokenandsignatureresultsize)를 호출합니다.

다음 예제는 사용자의 토큰과 Signature를 비동기적으로 가져오는 방법을 보여줍니다.

```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)

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

[XUserGetTokenAndSignatureResultSize](/reference/system/xuser/functions/xusergettokenandsignatureresultsize)


## Related topics

- [XUserGetTokenAndSignatureOptions](/ko/reference/system/xuser/enums/xusergettokenandsignatureoptions.md)
- [XUserGetTokenAndSignatureResult](/ko/reference/system/xuser/functions/xusergettokenandsignatureresult.md)
- [XUserGetTokenAndSignatureData](/ko/reference/system/xuser/structs/xusergettokenandsignaturedata.md)
- [XUserGetTokenAndSignatureResultSize](/ko/reference/system/xuser/functions/xusergettokenandsignatureresultsize.md)
- [XUserGetTokenAndSignatureHttpHeader](/ko/reference/system/xuser/structs/xusergettokenandsignaturehttpheader.md)
