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

# Kongregate와 HTML5를 사용하여 PlayFab 인증 설정하기

> HTML5와 JavaScript를 사용해 PlayFab 타이틀에 Kongregate 인증을 추가하는 단계별 튜토리얼로 Kongregate 앱 업로드와 플레이어 로그인을 다룹니다.

이 튜토리얼에서는 Kongregate와 HTML5/JavaScript를 사용하여 PlayFab에서 플레이어를 인증하는 데 필요한 최소한의 설정을 보여줍니다.

## 요구 사항

* 등록된 [Kongregate](https://www.kongregate.com/) 계정.
* [Kongregate 개발자 가이드](https://www.kongregate.com/developer_center/docs/en/kongregate-api)에 대한 이해.
* 등록된 PlayFab 타이틀.
* [로그인 기본 사항 및 모범 사례](/services/playfab/identity/player-identity/login/login-basics-best-practices)에 대한 이해.

## Kongregate 앱 설정

Kongregate는 필요한 API 정보에 액세스하기 전에 앱의 미리보기 버전을 업로드하도록 요구합니다.

이를 위해 다음 내용으로 `index.html` 파일을 준비해야 합니다.

```html theme={null}
<!doctype html>
<html lang="en-us">
<head></head>
<body>
 <h1>Placeholder</h1>
</body>
</html>
```

[Kongregate 웹사이트](https://www.kongregate.com/)로 이동합니다.

1. **Games** 탭을 선택합니다.
2. **Upload your game** 버튼을 선택합니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-games-tab.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=3af3bc93c645a3f8948701caf1f08d03" alt="Kongregate Games 탭" width="965" height="471" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-games-tab.png" />

새 애플리케이션을 설정하는 페이지가 열립니다.

1. **Title** 필드에 **애플리케이션 이름**을 입력합니다.
2. 그런 다음 제공된 필드에 **게임 설명**을 입력합니다.
3. **Category**를 선택합니다.
4. 아래 예시와 같이 **Continue** 버튼을 선택하여 새 앱을 제출합니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-upload-your-game.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=0e66a21c81da6861bd59d2dddb82c22f" alt="Kongregate 게임 업로드" width="636" height="603" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-upload-your-game.png" />

**Application Upload** 페이지로 이동합니다.

중요한 첫 단계로, **웹 주소 표시줄**의 **URL**을 반드시 저장하세요. 이는 페이지를 닫은 후 애플리케이션에 대한 액세스를 복원하려는 시간을 많이 절약해 줍니다.

1. 완료되면 준비한 **index.html** 파일을 **Game File**로 선택합니다.
2. 그런 다음 화면 크기를 설정합니다.
3. 필요한 모든 라이선스를 반드시 수락하세요.
4. 아래 예시와 같이 **Upload** 버튼을 선택하여 애플리케이션을 업로드합니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-app-upload-page.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=893af9198a1deef8b7cdb6bcd4534cc9" alt="Kongregate 애플리케이션 업로드 페이지" width="792" height="1120" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-app-upload-page.png" />

* 미리보기가 열리면 콘텐츠를 무시하고 **api information** 링크를 엽니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-preview-api-info.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=b136fa2e3dd827e4b6344921b500a8be" alt="Kongregate 미리보기 API 정보" width="786" height="432" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-preview-api-info.png" />

<Note>
  **API Information** 페이지가 열리면 **API Key**를 찾아 나중에 사용할 수 있도록 안전하고 쉽게 접근할 수 있는 곳에 저장하세요.
</Note>

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-api-key.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=a99770329d85ce86613cd0a32cdf28a4" alt="Kongregate API 키" width="900" height="344" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-api-key.png" />

## PlayFab 타이틀 구성

PlayFab 타이틀 Game Manager에서:

1. **Add-ons**로 이동합니다.
2. **Kongregate**를 찾아 선택합니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/playfab-select-kongregate-add-on.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=e25c251fc51474717d5b5a693ad1bf0c" alt="PlayFab Kongregate Add-on 선택" width="1100" height="685" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/playfab-select-kongregate-add-on.png" />

**Kongregate** 통합을 설정할 수 있는 새 페이지가 열립니다.

1. 이전 섹션에서 얻은 **API Key**를 입력합니다.
2. **Install Kongregate**를 선택합니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/playfab-set-up-kongregate-integration.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=fa6dd5111bfe1bb60c6cf118622272c1" alt="PlayFab Kongregate 통합 설정" width="1000" height="693" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/playfab-set-up-kongregate-integration.png" />

오류 메시지가 표시되지 않으면 Kongregate 애플리케이션과의 PlayFab 타이틀 통합이 구성되었습니다.

## 코드 준비

아래 표시된 예제 코드를 사용하여 게임의 `index.html`을 채웁니다.

```html theme={null}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
  <title>Kongregate Javascript API example</title>
  <!-- Import PlayFab API -->
  <script src='https://download.playfab.com/PlayFabClientApi.js'></script>
  <!-- Import JQuery, required specifically by this example, does not effect either API -->
  <script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js'></script>
  <!-- Import Kongregate API -->
  <script src='https://cdn1.kongregate.com/javascripts/kongregate_api.js'></script>
</head>

<!-- Define elements with IDs to show current state of things and a couple of buttons -->
<body style='background-color:white'>
  <span id='init'>Initializing...</span>
  <div id='content' style='display:none'>
    <div>Kongregate API Loaded!</div>
    <div id='username'></div>
    <div id='user_id'></div>
    <!-- This button will invoke Kongregate Auth Box -->
    <button id='login' style='display:none'
      onclick='kongregate.services.showRegistrationBox()'>Sign in/register</button>
    <!-- This button will invoke PlayFab authentication process -->
    <button id='login'
       onclick='loginInUsingPlayFab()'>PlayFab Login With Kongregate</button>
  </div>

  <script type='text/javascript'>

    // This function just updates UI, nothing else
    function updateFields() {
      $('#init').hide();
      $('#content').show();

      // Visualize Kongregate Auth Data
      $('#username').text('Username: ' + kongregate.services.getUsername());
      $('#user_id').text('User ID: ' + kongregate.services.getUserId());

      // If not authenticated in Kongregate, allow to use Login button
      if(kongregate.services.isGuest()) {
        $('#login').show();
      } else {
        $('#login').hide();
      }
    }

    // The function prepares and triggers PlayFab LoginWithKongregate API call
    function loginInUsingPlayFab() {
      // Setting up PlayFab title ID
      PlayFab.settings.titleId = "159F";

      // forming request
      var request = {
        TitleId: PlayFab.settings.titleId,
        AuthTicket: kongregate.services.getGameAuthToken(),
        KongregateId : kongregate.services.getUserId(),
        CreateAccount: true
      };

      console.log('logging in');
      // Invoke LoginWithKongregate API call and visualize both results (success or failure)
      PlayFabClientSDK.LoginWithKongregate(request,
      function(result){
        $('<div></div>').html('Authenticated via playfab').appendTo('#content')
        console.log("success");
      },
      function(err){
        $('<div></div>').html('Problem occurred: ' + PlayFab.GenerateErrorReport(err)).appendTo('#content')
        console.log("failure");
      });
    }

    // The entry point for Kongregate initialization
    kongregateAPI.loadAPI(function(){
      window.kongregate = kongregateAPI.getAPI();
      updateFields();
      kongregate.services.addEventListener('login', function(){
        updateFields();
      });
    });
  </script>
</body>
</html>
```

## 테스트

조금 전에 안전하고 접근하기 쉬운 곳에 저장하도록 요청한 URL을 기억하시나요? 이제 이를 사용하여 **Application Upload** 페이지에 접근합니다.

1. **index.html**을 **Game File**로 선택합니다.
2. 화면 크기를 설정합니다.
3. 필요한 모든 라이선스를 반드시 수락하세요.
4. **Upload** 버튼을 선택하여 애플리케이션을 업로드합니다.

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-app-upload-page.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=893af9198a1deef8b7cdb6bcd4534cc9" alt="Kongregate 애플리케이션 업로드 페이지" width="792" height="1120" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-app-upload-page.png" />

미리보기가 로드되면 애플리케이션이 **Kongregate User ID**와 **Username**을 얻을 때까지 기다립니다.

* 그렇게 되면 **PlayFab Login With Kongregate** 버튼을 선택합니다.
* 잠시 후에 **Authenticated via PlayFab** 메시지를 받아야 합니다.
* 이 시점에서 PlayFab와 Kongregate를 사용하여 성공적으로 로그인했습니다!

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-html5/testing-playfab-login-with-kongregate.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=f0588d425c650246a5a9f8a041b3a078" alt="Kongregate로 PlayFab 로그인 테스트" width="905" height="467" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/kongregate-html5/testing-playfab-login-with-kongregate.png" />


## Related topics

- [Twitch와 HTML5를 사용하여 PlayFab 인증 설정하기](/ko/services/playfab/identity/player-identity/platform-specific-authentication/twitch-html5.md)
- [Google과 HTML5를 사용하여 PlayFab 인증 설정하기](/ko/services/playfab/identity/player-identity/platform-specific-authentication/google-html5.md)
- [Facebook과 HTML5를 사용하여 PlayFab 인증 설정하기](/ko/services/playfab/identity/player-identity/platform-specific-authentication/facebook-html5.md)
- [Kongregate와 Unity를 사용하여 PlayFab 인증 설정하기](/ko/services/playfab/identity/player-identity/platform-specific-authentication/kongregate-unity.md)
- [PlayFab용 Battle.net 로그인 설정하기](/ko/services/playfab/identity/player-identity/platform-specific-authentication/battlenet-login.md)
