Vue 3 Google 登录用户身份验证在控制台中显示弃用警告

Vue 3 Google Sign-In User Authentication shows deprecated warning in console

我正在尝试在我的 Vue 3 应用程序中使用 Google 功能实现登录,我发现了一些 npm 包来实现这个功能,但是这些包很快就会被弃用 (This warning is shown in console).

我喜欢使用 Google Identity Services 将使用 Google 登录功能添加到我的 Web 应用程序中,该应用程序提供一键注册和自动登录等功能,我如何才能轻松实现Vue 3 中的此功能?

我创建了一个小插件 vue3-google-login which uses Google Identity Services 来实现 Google、One-tap sign-up 和自动 sign-in.[=15 等登录功能=]

这是使用 vue3-google-login

创建简单 Google 登录按钮的示例代码

第一个initialise the plugin in main.js with your Google API client ID

import { createApp } from 'vue'
import App from './App.vue'
import vue3GoogleLogin from 'vue3-google-login'

const app = createApp(App)

app.use(vue3GoogleLogin, {
  clientId: 'YOUR_GOOGLE_CLIENT_ID'
})

app.mount('#app')

然后像这样使用Google登录组件

<script setup>
const callback = (response) => {
  console.log("Handle the response", response)
}
</script>

<template>
  <GoogleLogin :callback="callback"/>
</template>