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

# XStoreQueryLicenseTokenAsync

> XStoreQueryLicenseTokenAsync

# XStoreQueryLicenseTokenAsync

호출하는 게임에 불투명한 JSON 웹 토큰을 제공하며, 이 토큰을 게임 서비스에 전달하여 사용 권한을 확인하고 B2B 호출을 수행할 수 있습니다. 자세한 내용은 [라이선스 토큰 개요](/publishing/xstore-commerce/xstore-license-tokens)를 참조하세요.

## 구문

```cpp theme={null}
HRESULT XStoreQueryLicenseTokenAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char** productIds,  
         size_t productIdsCount,  
         const char* customDeveloperString,  
         XAsyncBlock* async  
)  
```

### 매개 변수

*storeContextHandle*   \_In\_\
형식: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)에서 반환된 사용자의 스토어 컨텍스트 핸들입니다.

*productIds*   \_In\_z\_count\_(productIdsCount)\
형식: char\*\*

토큰을 검색할 제품 ID의 배열입니다.

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

**productIds**에 전달된 배열에 있는 ID의 수입니다.

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

토큰에 왕복 전달되는 값입니다. 일반적으로 서비스에 의해 선택됩니다. userId나 이메일과 같은 값을 삽입하여 라이선스 토큰에서 사용자의 토큰을 추적할 수 있습니다. 라이선스 토큰은 소유권 영수증과 같이 사용됩니다.

null이거나 빈 문자열이면 안 됩니다.

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

수행 중인 비동기 작업을 정의하는 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)입니다. [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)을 사용하여 호출 상태를 폴링하고 호출 결과를 검색할 수 있습니다. 자세한 내용은 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)을 참조하세요.

### 반환 값

형식: HRESULT

HRESULT 성공 또는 오류 코드입니다.

## 설명

이 함수의 실행 결과와 JSON 웹 토큰을 검색하려면 이 함수를 호출한 후 [XStoreQueryLicenseTokenResult](/reference/system/xstore/functions/xstorequerylicensetokenresult)를 호출합니다. JSON 웹 토큰의 크기를 검색하려면 이 함수를 호출한 후 [XStoreQueryLicenseTokenResultSize](/reference/system/xstore/functions/xstorequerylicensetokenresultsize)를 호출합니다. 토큰의 크기를 알면 더 효율적으로 검색할 수 있습니다.

라이선스 토큰은 Base64로 인코딩된 JSON 웹 토큰입니다. 토큰의 페이로드는 Base64로 인코딩된 문자열이며, 서버에서 유효성 검사에 사용할 수 있는 JSON 값으로 변환됩니다.

다음 코드 조각은 라이선스 토큰을 검색하는 예를 보여줍니다.

```cpp theme={null}
void CALLBACK QueryLicenseTokenCallback(XAsyncBlock* asyncBlock)
{
    size_t size;
    HRESULT hr = XStoreQueryLicenseTokenResultSize(
        asyncBlock,
        &size);

    if (FAILED(hr))
    {
        printf("Failed retrieve the license token size: 0x%x\r\n", hr);
        return;
    }

    char* result = new char[size];
    hr = XStoreQueryLicenseTokenResult(
        asyncBlock,
        size,
        result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the license token result: 0x%x\r\n", hr);
        delete[] result;
        return;
    }

    printf("result: %s\r\n", result);

    delete[] result;
}

void QueryLicenseToken(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char** productIds, size_t productIdsCount, const char* customDeveloperString)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = QueryLicenseTokenCallback;

    HRESULT hr = XStoreQueryLicenseTokenAsync(
        storeContextHandle,
        productIds,
        productIdsCount,
        customDeveloperString,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get license token: 0x%x\r\n", hr);
        return;
    }
}
```

## 요구 사항

**헤더:** XStore.h (XGameRuntime.h에 포함됨)

**라이브러리:** xgameruntime.lib

**지원 플랫폼:** Windows, XBOX One 제품군 콘솔 및 XBOX Series 콘솔

## 개념 설명서

* [플레이어에게 추가 기능 콘텐츠에 대한 액세스 권한 부여](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)
* [라이선스 테스트 사용](/publishing/xstore-commerce/xstore-licensing-setup)
* [기본 DRM 및 라이선스 검사](/publishing/xstore-commerce/xstore-pc)
* [라이선스 토큰을 사용하여 서비스에서 라이선스 유효성 검사하기](/publishing/xstore-commerce/xstore-license-tokens)

## 참고 항목

[XStore](/reference/system/xstore/xstore_members)

[라이선스 토큰 개요](/publishing/xstore-commerce/xstore-license-tokens)

[XStoreQueryLicenseTokenResult](/reference/system/xstore/functions/xstorequerylicensetokenresult)

[XStoreQueryLicenseTokenResultSize](/reference/system/xstore/functions/xstorequerylicensetokenresultsize)


## Related topics

- [XStoreQueryLicenseTokenResult](/ko/reference/system/xstore/functions/xstorequerylicensetokenresult.md)
- [XStoreQueryLicenseTokenResultSize](/ko/reference/system/xstore/functions/xstorequerylicensetokenresultsize.md)
- [PC의 XStore — DRM, 라이선스 토큰, 샌드박스](/ko/publishing/xstore-commerce/xstore-pc.md)
- [라이선싱 테스트 활성화](/ko/publishing/xstore-commerce/xstore-licensing-setup.md)
- [플레이어에게 추가 기능 콘텐츠 액세스 부여](/ko/publishing/xstore-commerce/xstore-granting-access.md)
