다음을 통해 공유


XGameUiShowWebAuthenticationWithOptionsAsync

사용자가 자격 증명을 실행 중인 타이틀에 직접 제공하지 않고 외부 사이트 및 서비스에 대한 액세스를 위임할 수 있도록 웹 UI(전체 화면)를 표시하는 비동기 인증 요청을 시작합니다.

구문

STDAPI XGameUiShowWebAuthenticationWithOptionsAsync(
    _In_ XAsyncBlock* async,
    _In_ XUserHandle requestingUser,
    _In_z_ const char* requestUri,
    _In_z_ const char* completionUri,
    _In_ XGameUiWebAuthenticationOptions options
    ) noexcept;
)  

매개 변수

async _In_
형식: XAsyncBlock*

XAsyncRun에 전달된 XAsyncBlock에 대한 포인터입니다.

requestingUser _In_
형식: XUserHandle

웹 인증을 요청하는 사용자에 대한 핸들입니다.

requestUri _In_z_
형식: char*

사용자에게 표시되는 웹 보기의 초기 URI입니다(서비스에 대한 사용자 인증 필드가 포함될 가능성이 높음). 요청 URI는 보안 HTTPS 주소여야 합니다.

completionUri _In_z_
형식: char*

웹 인증 프로세스의 성공적인 완료를 나타내는 URI를 나타냅니다. 웹 보기가 completionUri와 일치하는 URI로 탐색되면 웹 보기가 닫히고 컨트롤은 호출 타이틀로 반환됩니다.

옵션 &nbps; _In_ 형식: XGameUiWebAuthenticationOptions

UI를 전체 화면으로 표시할지 여부를 나타내는 플래그입니다. PC에서 이 플래그는 무시됩니다. 전체 화면은 PC에서 지원되는 옵션이 아닙니다.

반환 값

형식: HRESULT

비동기 호출의 HRESULT 성공 또는 오류 코드입니다.

결과를 가져오기 위해 AsyncBlock 콜백 내에서 또는 AsyncBlock이 완료된 후에 xgameuishowwebauthenticationresultsizexgameuishowwebauthenticationresult를 호출합니다.

설명

비동기 작업 실행 시 시스템에서 사용자에게 웹 보기가 표시되고(현재 애플리케이션과 중첩되지 않음), 이를 사용하여 상호 작용하거나 뒤로 눌러 무시할 수 있습니다. 이를 통해 사용자는 OAuth를 사용하여 외부 웹 사이트 및 서비스에 권한을 부여할 수 있습니다. 이는 소셜 미디어에 게임 하이라이트를 공유하기 위해 게임 인증을 하는 것부터 외부 공급자로부터 사용자 데이터를 요청하는 등의 시나리오에서 사용할 수 있습니다.

인증의 결과는 XGameUiWebAuthenticationResultData 개체에 저장되며, 이 개체는 XGameUiShowWebAuthenticationResult 메서드에서 반환됩니다.

completionUri로 이동하면서 웹 보기가 닫힌 경우 결과 데이터 구조의 responseStatus 필드는 S_OK가 됩니다.

사용자가 웹 보기를 취소하거나 수동으로 닫은 경우 결과 데이터 구조의 responseStatus 필드는 E_CANCELLED가 됩니다.

예제

다음 코드 예제에서는 Facebook을 사용하여 OAuth를 수행하는 방법을 보여줍니다. 이 예제에서는 코드를 간단하게 유지하기 위해 메모리 할당 오류 처리가 포함되지 않습니다.

// Use Facebook example for OAuth; client_id should correspond to your registered application.
const char completionUri[] = "https://www.facebook.com/connect/login_success.html"; 
const char requestUri[] =
    "https://www.facebook.com/dialog/oauth?"
    "client_id=000000000000000&"
    "redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html&"
    "response_type=token&"
    "sdk=xboxone";

// Allocate and initialize XAsyncBlock for asynchronous authentication operation.
XAsyncBlock* block = new XAsyncBlock();
ZeroMemory(block, sizeof(XAsyncBlock));
block->callback = [](XAsyncBlock* block)
{
    // Query required size and allocate buffer for authentication result data.
    uint32_t bufferSize = 0;
    FAIL_FAST_IF_FAILED(XGameUiShowWebAuthenticationResultSize(block, &bufferSize));
    uint8_t* buffer = new uint8_t[bufferSize];

    // The currentUser is initialized with user to authenticate for.
    XGameUiWebAuthenticationResultData* resultData = nullptr;
    FAIL_FAST_IF_FAILED(XGameUiShowWebAuthenticationResult(
        block,
        bufferSize,
        buffer,
        &resultData,
        nullptr
        ));

    //
    // Use the result data here. If resultData->responseStatus is S_OK, then web authentication was successful.
    //

    // Free allocated buffer and XAsyncBlock.
    delete[] buffer;
    delete block;
};

//  Begin asynchronous authentication operation.
XUserHandle currentUser = GetCurrentUserForAuthentication();
FAIL_FAST_IF_FAILED(XGameUiShowWebAuthenticationWithOptionsAsync(
    block,
    currentUser,
    requestUri,
    completionUri,
    XGameUiWebAuthenticationOptions::PreferFullscreen
    ));

요건

헤더: XGameUI.h

라이브러리: xgameruntime.lib

지원되는 플랫폼: Windows, Xbox One 패밀리 콘솔 및 Xbox Series 콘솔

참고 항목

XGameUIXGameUiShowWebAuthenticationAsync
XGameUiShowWebAuthenticationResultSize
XGameUiShowWebAuthenticationResult
XGameUiWebAuthenticationResultData
비동기 프로그래밍 모델