laravel-passport-socialite
laravel-passport-socialite copied to clipboard
Cannot get oAuth token or get this package to work
@anandsiddharth thanks for the effort but I am trying to get this working as an end-to-end example so I can both move on to other parts of my app, and that this helps more people that are stuck. I'm just not able to figure out how to get this working.
Here's my code. I followed all the instructions in the readme. I even included some sample github and google API keys in my .env.example, so you can copy that as-is for your .env file.
https://gitlab.com/connecteev/_laravel_auth_socialite_with_laravel_passport/tree/schedula_laravel_passport_socialite I also created a readme which contains the setup instructions. I also recorded some short videos in trying to get this (and social auth in general using laravel passport + socialite) working.
I'm stuck on step 1 and am not able to get a valid token. POST http://localhost:8000/api/auth/social/github
This is the error I get back:
{
"error": "Client error: `GET https://api.github.com/user?access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODAwMFwvYXBpXC92MVwvYXV0aFwvbG9naW5cL2dpdGh1YlwvY2FsbGJhY2siLCJpYXQiOjE1NzE0NDQyMDgsImV4cCI6MTU3MTQ0NzgwOCwibmJmIjoxNTcxNDQ0MjA4LCJqdGkiOiJrNjlTNHpNZ041dUhLSUtwIiwic3ViIjoyOCwicHJ2IjoiODdlMGFmMWVmOWZkMTU4MTJmZGVjOTcxNTNhMTRlMGIwNDc1NDZhYSJ9.Kbfia0I_SovgjyRsu1CVrxHWqhTKF6UBeS7aKnDlZPQ` resulted in a `401 Unauthorized` response:\n{\n \"message\": \"Bad credentials\",\n \"documentation_url\": \"https://developer.github.com/v3\"\n}\n\n"
}
What am I doing wrong? How can we make this more dummy-proof (and I realize I may be the dummy here)? What would be awesome is if we can get this working and then use that as a reference going forward, possibly even in a "demo" or "example" branch in this repo itself.
Please advise...
I see that in your passport auth PHP code. You are not using client id and secret comming from the request you are fetching that information using config
@anandsiddharth do you mean in this file? Any chance you could submit a PR to help get the initial token? Would be helpful.
This is wrong
$params = [
'grant_type' => 'social',
'client_id' => env('PASSPORT_PASSWORD_GRANT_CLIENT_ID'),
'client_secret' => env('PASSPORT_PASSWORD_GRANT_CLIENT_SECRET'),
'accessToken' => $accessToken, // access token from provider
'provider' => $provider, // i.e. google, facebook, etc
];
Not wrong exactly in case you update your .env file every time you create a passport client then it's okay.
Let me know if your issue is resolved. So that I can close this ticket!
Didn't quite fix it....I havent been able to get the package to work...but if you want to close the ticket that's okay..
Please do mention the fix! let me know if there was any problem with the package maybe we can work together to improve the package and let not others face the problem.
@anandsiddharth I didn't get this package working, but if you'd like me to be a guinea pig and make this user-friendly, I'm happy to. I have emailed you my contact info if you want to work together. Kunal
Did you try this https://github.com/schedula/laravel-passport-socialite/issues/12#issuecomment-544233930
@anandsiddharth yes, that doesnt do anything though...it gets the keys from my env file, which is working fine. I have a migration for my passport client credentials, so they dont change every time.
If sharing your .env file is okay, would you mind emailing it to me? So I can run the tests!
sent
Cool I will be checking on that over the weekend, will update here