Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add facebook scheme #73

Closed
pi0 opened this issue Feb 19, 2018 · 3 comments
Closed

Add facebook scheme #73

pi0 opened this issue Feb 19, 2018 · 3 comments

Comments

@pi0
Copy link
Member

pi0 commented Feb 19, 2018

original request by @syffs

I've tried adding a facebook scheme, not sure I got it right though...
SSR is not working and I'm not sure how accessToken is supposed to be sent back to the server. Any insight?
I also though about implementing this without SDK not sure what is the preferred way..

This feature request is available on Nuxt.js community (#c55)
@syffs
Copy link
Contributor

syffs commented Feb 26, 2018

Thanks, Facebook provider using oauth2 scheme works perfectly.

It would be great to be able to adjust hardcoded providers parameters (mainly scope and userinfo_endpoint) through strategies into nuxt.config.js. I've tried setting these setups unsuccessfully:

  • Add custom endpoint & scope to existing facebook strategy
      facebook: {
        client_id: '1671464192946675',
        userinfo_endpoint: 'https://graph.facebook.com/v2.12/me?fields=about,name,picture{url},email,birthday,friends',
        scope: ['public_profile', 'email', 'user_friends', 'user_birthday']
      },

These changes are needed for this to work

  • Custom strategy as in here:
      fb: {
        _scheme: 'oauth2',
        client_id: '1671464192946675',
        authorization_endpoint: 'https://facebook.com/v2.12/dialog/oauth',
        userinfo_endpoint: 'https://graph.facebook.com/v2.12/me?fields=about,name,picture{url},email,birthday,friends',
        scope: ['public_profile', 'email', 'user_friends', 'user_birthday']
      },

edit: Actually, 2nd option seems to work even though 1st one would be more elegant
I was getting some strange error at first, but it must have been due to previous cookie:

{ TypeError: Cannot read property 'mounted' of undefined
    at Auth.mounted (.nuxt/auth/auth.js:245:0)
    at Auth.init (.nuxt/auth/auth.js:39:0)
    at module.exports.__webpack_exports__.a (.nuxt/auth/plugin.js:33:0)
    at createApp (.nuxt/index.js:156:0)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) statusCode: 500, name: 'TypeError' }

@syffs
Copy link
Contributor

syffs commented Feb 26, 2018

Another question: Have you though about a specific way of sending accessToken or code to a specific endpoint in the callback?
Usually after social authentication, accessToken or code is sent to your webserver for long-lived-access-token generation, database provisioning and later access.

I see that Oauth2Scheme._handleCallback only pushes authorization code to access_token_endpoint when this.options.response_type === 'code', but Facebook API allows response_type=code%20token (I don't know about other providers)

@pi0
Copy link
Member Author

pi0 commented Apr 3, 2018

The Facebook scheme is basically working. I would let enhancement to be done in new issues and PRs.

@pi0 pi0 closed this as completed Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants