为什么在 nuxt-auth-next 中 google 授权后用户未通过身份验证?
Why user is not authenticated after google authorization in nuxt-auth-next?
我在我的 nuxt 应用程序中使用以下 nuxt-auth-next 配置
nuxt.config.js
auth: {
strategies:{
google: {
clientId: "my_client_id.apps.googleusercontent.com",
redirectUri: `http://localhost:3000/apps`,
codeChallengeMethod: '',
scope: ['profile', 'email'],
responseType: 'token id_token'
}
},
redirect: {
login: '/login',
logout: false,
home: '/apps',
callback: false
}
},
router: {
middleware: ['auth']
}
这是我的 login.vue
文件
<template>
<div>
<div>
<template>
<b-button @click="loginClicked()">Login with Google</b-button>
</template>
</div>
</div>
</template>
<script>
export default {
methods: {
async loginClicked() {
try {
await this.$auth.loginWith('google');
} catch (err) {
console.log("login error: " + err);
}
}
}
}
</script>
当我在登录页面按使用Google登录按钮时,它进入Google认证页面,成功通过认证,进入localhost:3000/apps 页面(我的重定向 url),然后立即 returns 到 localhost:3000/login - this.$auth.loggedIn 是 false.
我已经访问过 https://github.com/nuxt-community/auth-module/issues/1127,但这没有帮助。我错过了什么吗?
"@nuxtjs/auth-next": "5.0.0-1624817847.21691f1",
"nuxt": "^2.15.8"
Vue devtools 在我按下 'Login with Google' 之后
如 this page 所述,auth-next
又名 v5 仍处于测试阶段,您可能会遇到一些错误,即使它的功能更丰富。
如果您对 Nuxt 模块随 v4 提供的功能没问题,坚持使用它可能是更稳定的解决方案。
我在我的 nuxt 应用程序中使用以下 nuxt-auth-next 配置
nuxt.config.js
auth: {
strategies:{
google: {
clientId: "my_client_id.apps.googleusercontent.com",
redirectUri: `http://localhost:3000/apps`,
codeChallengeMethod: '',
scope: ['profile', 'email'],
responseType: 'token id_token'
}
},
redirect: {
login: '/login',
logout: false,
home: '/apps',
callback: false
}
},
router: {
middleware: ['auth']
}
这是我的 login.vue
文件
<template>
<div>
<div>
<template>
<b-button @click="loginClicked()">Login with Google</b-button>
</template>
</div>
</div>
</template>
<script>
export default {
methods: {
async loginClicked() {
try {
await this.$auth.loginWith('google');
} catch (err) {
console.log("login error: " + err);
}
}
}
}
</script>
当我在登录页面按使用Google登录按钮时,它进入Google认证页面,成功通过认证,进入localhost:3000/apps 页面(我的重定向 url),然后立即 returns 到 localhost:3000/login - this.$auth.loggedIn 是 false.
我已经访问过 https://github.com/nuxt-community/auth-module/issues/1127,但这没有帮助。我错过了什么吗?
"@nuxtjs/auth-next": "5.0.0-1624817847.21691f1",
"nuxt": "^2.15.8"
Vue devtools 在我按下 'Login with Google' 之后
如 this page 所述,auth-next
又名 v5 仍处于测试阶段,您可能会遇到一些错误,即使它的功能更丰富。
如果您对 Nuxt 模块随 v4 提供的功能没问题,坚持使用它可能是更稳定的解决方案。