首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nuxt Auth扩展/修改Google Social

Nuxt Auth扩展/修改Google Social
EN

Stack Overflow用户
提问于 2021-09-24 15:44:06
回答 1查看 460关注 0票数 1

我已经建立了使用django /django的社会认证。端点期望此信息为JSON:

不幸的是,在我看来,就像Nuxt一样,假设后端应该从URL中提取信息,尽管它将其作为POST请求发送。所以所发生的是:我点击“继续使用Google > Nuxt”将我推到google > Google将我推到回调URL上,其中包含了URL中的所有信息。Nuxt获取这个URL,然后按原样发送出去。

所以我有两个选择:

我是否尝试修改后端,这感觉相当troublesome.

  • Do,我以某种方式重写了Nuxt?我在这里很无知。--

文档讨论如何创建自定义方案:https://auth.nuxtjs.org/guide/scheme

但从那时起,我真的无法理解如何定制实际的生成的post请求。我会感谢你的帮助。

我的NUXT.CONFIG.JS:

代码语言:javascript
复制
auth: {
    redirect: {
      login: '/register',
      logout: false,
      // callback: '/login',
      home: '/bevakning'
    },
    strategies: {
      google: {
        scope: ['profile', 'email'],
        codeChallengeMethod: '',
        responseType: 'code',
        endpoints: {
          token: 'http://localhost:8000/social-login/google/',
          userInfo: 'http://localhost:8000/auth/user/'
        },
        // withCredentials: true,
      },
      local: {
        token: {
          property: 'key',
          type: 'Token ',
          maxAge: 86400 * 120
        },
        user: {
          // using property: false means it will use the entire json response as user and not just one variable.
          property: false
          // property: 'email'
        },
        endpoints: {
          login: {
            url: '/dj-rest-auth/login/ ',
            method: 'post',
            // propertyName: 'auth_token'
          },
          logout: {
            url: '/dj-rest-auth/logout/',
            method: 'post'
          },
          user: {
            url: '/dj-rest-auth/user/',
            method: 'get',
          }
        },
        // tokenRequired: true,
        // tokenType: 'Token ',
        // globalToken: true,
        autoFetchUser: true,
      }
    }
  },

编辑:解决了我的问题,这不是讽刺的原因是Axios凌驾于nuxt方法之上。当内容类型被设置为JSON时,我意识到有些东西被关闭了,但是身体被发送,就好像它是x-www-urlencoded一样。

EN

回答 1

Stack Overflow用户

发布于 2021-09-24 18:35:14

结果发现,这个问题与我用Axios全局添加一个应用程序/json头有关。axios:{ // baseURL:'http://localhost:8000/',超时值: 30,标题:{公用:{“Content”:"application/json",接受:"application/json",},}

这导致了对Nuxt Auth POST请求的x-www-urlencoded格式的错误解释。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69317812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档