我尝试使用以下链接使用 Nuxt.js 使用 auth-module 构建 Facebook 登录。
https://github.com/nuxt-community/auth-module
我无法获得“access_token”。代码如下。
// pages/login.vue
export default {
methods: {
this.$auth.loginWith('facebook')
}
}
回调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 不包含“access_token”。我怎样才能得到“access_token”? 我也不明白为什么 URI 在获取参数字段中包含“#”。因此,我无法从“this.$route.query”获取 access_token。
最佳答案
最后,我可以用下面的代码来做到这一点。
this.$auth.getToken('facebook')
感谢各位观看。
关于javascript - 如何从 auth-module Nuxt.js 获取 access_token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55430384/