简体   繁体   English

如何从 auth-module、Nuxt.js 获取 access_token

[英]How can I get access_token from auth-module, Nuxt.js

I try to build Facebook login with auth-module the link below with Nuxt.js.我尝试使用以下链接使用 Nuxt.js 使用 auth-module 构建 Facebook 登录。

https://github.com/nuxt-community/auth-module https://github.com/nuxt-community/auth-module

I can not get "access_token".我无法获得“access_token”。 the code is follows.代码如下。

// pages/login.vue
export default {
   methods: {
       this.$auth.loginWith('facebook')
   }
}

the call back URI is like this.回调URI是这样的。

https://localhost:3000/facebook/oauth_callback/?#access_token=***&data_access_expiration_time=1561715202&expires_in=4398&reauthorize_required_in=7776000&state=MC4xOTU3MDM2ODIxMzIzOTA5OA
// pages/facebook/oauth_callback/index.vue
<template>
  <section>
    <p>{{ this.$auth.$state }}</p>
    <p>{{ this.$route.query }}</p
  </section>
</template>

this.$auth.$state don't include "access_token". this.$auth.$state 不包括“access_token”。 How can I get "access_token"?我怎样才能获得“access_token”? I don't also understand why the URI include "#" in get parameter field.我也不明白为什么 URI 在获取参数字段中包含“#”。 because of it, I can't get access_token from "this.$route.query".因此,我无法从“this.$route.query”获取 access_token。

Finally, I can do this with following code.最后,我可以使用以下代码来做到这一点。

this.$auth.getToken('facebook')

Thanks for watching it guys.谢谢大家观看。

This worked for me:这对我有用:

this.$auth.strategy.token.get()

Source: github.com/nuxt-community/auth-module来源: github.com/nuxt-community/auth-module

It may only be for the dev release.它可能仅适用于开发版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM