首页 > 解决方案 > Nuxt.js/auth-next,如何接收google用户信息和用户ID?

问题描述

我正在尝试将 Nuxt.js 集成Nuxt/auth-next到我的应用程序中,我试图仅从 Google 接收用户 ID 并将此用户 ID 发送到我的后端服务器,在重定向期间,我无法在回调中接收用户信息,我做错了吗?

 auth: {
    redirect: {
      login: '/',
      logout: '/',
      home: '/'
    },
    strategies: {
      local: {
        token: {
          property: 'user.token',
        },
        user: {
          property: false
        },
        endpoints: {
          login: { url: 'api/login', method: 'post'},
          logout: { url: 'logout', method: 'post' },
          user: { url: 'api/user', method: 'get' }
        },
      },
      google: {
        clientId: 'googleClientId',
        redirectUri: `http://localhost:3000/`,
        codeChallengeMethod: "",
        responseType:"code",
        scope: ['profile', 'email'],
      },
    },
    cookie: {
      prefix: 'auth.',
    }
  },

testLoginWith(){
this.$auth.loginWith('google', { params: { prompt: "select_account"} }).then( result => console.log(result) )}

标签: vue.jsnuxt.js

解决方案


推荐阅读