Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I try to build Facebook login with auth-module the link below with Nuxt.js.

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

I can not get "access_token". the code is follows.

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

the call back URI is like this.

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". How can I get "access_token"? I don't also understand why the URI include "#" in get parameter field. because of it, I can't get access_token from "this.$route.query".

like image 316
yoshinbo Avatar asked Mar 30 '19 10:03

yoshinbo


2 Answers

Finally, I can do this with following code.

this.$auth.getToken('facebook') 

Thanks for watching it guys.

like image 73
yoshinbo Avatar answered Sep 26 '22 01:09

yoshinbo


This worked for me:

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

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

It may only be for the dev release.

like image 36
DevonDahon Avatar answered Sep 27 '22 01:09

DevonDahon