Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

Cannot get Facebook acces_token from OAuth login

I'm using Nuxt Auth to allow users to login through their Facebook account:

const accessToken = this.$auth.getToken('facebook')
this.$axios.$get(`https://graph.facebook.com/v8.0/me?access_token=${accessToken}`)
  .then((response) => {
    console.log(response)
  })

When I run this code I get an error:

Access to XMLHttpRequest at 'https://graph.facebook.com/v8.0/me?access_token=Bearer%

When I use the https://developers.facebook.com/ tool I can get the correct data. And when I replace my acces token with the Facebook Explorer Acces token:

const accessToken = 'EAAJxZBa24EDUBAHQJA49iRczw6mUvlOnLwtFBowWsNzZC36eBGpUx8l9vIs0Nai7Tj8l9SZBAvntDREu2dOd6ZBhk0ZAERYG7JU537YO5bXrx7IjWptkscJNGNk6m9TOvcm9FDtDOg5I4HC0fVphCLPKZBdCQVWZC1XHMa5nQ6ZA*************'
this.$axios.$get(`https://graph.facebook.com/v8.0/me?access_token=${accessToken}`)
  .then((response) => {
    console.log(response)
  })

Than the error disappears and I get the correct data.

So it looks like the const accessToken = this.$auth.getToken('facebook') doesn't return a correct Facebook acces token. It returns a Bearer token.

How do I grab a Facebook acces token by using Nuxt Auth?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...