TossAuth.login
函数式 API
appLogin也可以这样使用同样的功能。
功能说明
使用 Toss 认证登录。登录完成后会再次跳转到 Toss 应用。返回的 authorizationCode和 referrer将其传给服务器,继续进行登录处理即可。
类型
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);
}
});这有帮助吗?