For the complete documentation index, see llms.txt. This page is also available as Markdown.

TossAuth.login

함수형 API appLogin으로도 같은 기능을 쓸 수 있어요.

기능 설명

토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요. 반환된 authorizationCodereferrer를 서버로 전달해 로그인 처리를 이어가면 돼요.

타입

TossAuth.login(): Promise<AppLoginResponse>;

Params

없음

Response

type AppLoginResponse = {
  authorizationCode: string;
  referrer: "DEFAULT" | "SANDBOX";
};

예시 코드

import { TossAuth } from "@apps-in-toss/web-framework";

const button = document.querySelector("#login-button");

button.addEventListener("click", async () => {
  try {
    const { authorizationCode, referrer } = await TossAuth.login();
    // authorizationCode와 referrer를 서버로 전달해요
  } catch (error) {
    console.error(error);
  }
});

도움이 되었나요?