joselfonseca / lighthouse-graphql-passport-auth

Add GraphQL mutations to get tokens from passport for https://lighthouse-php.com/
https://lighthouse-php-auth.com/
MIT License
229 stars 56 forks source link

socialLogin #100

Closed stephenjason89 closed 4 years ago

stephenjason89 commented 4 years ago

Thank you for your work,

Everything is working excellent besides the socialLogin

I'm trying this mutation{ socialLogin(input:{ provider: "FACEBOOK" token: "EAAECNZCTBZBJ4BAHCFZBmoh8crfUlfJf1y7REO0mVUiHH7c2J45lZCUpoyp4jmDklBHNQ3dCln55Bq2j0cNM2CbDlZBiUPXRmqjcja2XoZBH6NYguVAVKjtCLJAOLJowtNr3qgpp7ZCRZC0TsuhNMZAt0MkrvN4tTaw0ZD" }){ access_token refresh_token user{ id name } } }

but the response was "message": "Authentication exception", "extensions": { "reason": "Incorrect username or password", "category": "authentication" },

I can verify that normal socialite login is working on my end.

I might be doing something wrong on getting the token?

I would really appreciate if you provide a working git example.

Thank you

stephenjason89 commented 4 years ago

I can get the token when:

  1. the user logs in using a redirect to facebook on my login.blade
  2. then facebook callbacks my socialcontroller@callback method

there I can $socialUser = Socialite::driver($provider)->stateless()->user(); then access the token by $socialUser->token

but how would I login and call mutation on graphql socialLogin from that controller?

I might be missing something.

Thank you so much

joselfonseca commented 4 years ago

We are using this in many apps already and haven't had this issue. It may be a problem in the configuration or the user permissions for the email.

stephenjason89 commented 4 years ago

Hello thank you for taking the time to reply,

is there a working repo where I can see a sample code?

can you elaborate more on how it works?

provider is a string ('facebook','google' etc..) then token is access token returned from the user upon registration? Or token returned by facebook or google?

should I also prefix it with "Bearer " ?

Also where will it check the value on the database? my structure is Users hasmany social_accounts then social_accounts belongs to a user

Thank you

joselfonseca commented 4 years ago

Closing due to inactivity, please open a new Issue if you are still having problems. We have not been able to reproduce this.