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

Cannot get oAuth token or get this package to work #12

Open
connecteev opened this issue Oct 19, 2019 · 12 comments
Open

Cannot get oAuth token or get this package to work #12

connecteev opened this issue Oct 19, 2019 · 12 comments

Comments

@connecteev
Copy link

@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...

@anandsiddharth
Copy link
Collaborator

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

@connecteev
Copy link
Author

@anandsiddharth do you mean in this file?
Any chance you could submit a PR to help get the initial token? Would be helpful.

@anandsiddharth
Copy link
Collaborator

anandsiddharth commented Oct 20, 2019

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.

@anandsiddharth
Copy link
Collaborator

Let me know if your issue is resolved. So that I can close this ticket!

@connecteev
Copy link
Author

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..

@anandsiddharth
Copy link
Collaborator

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.

@connecteev
Copy link
Author

@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

@anandsiddharth
Copy link
Collaborator

Did you try this #12 (comment)

@connecteev
Copy link
Author

connecteev commented Oct 21, 2019

@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.

@anandsiddharth
Copy link
Collaborator

If sharing your .env file is okay, would you mind emailing it to me? So I can run the tests!

@connecteev
Copy link
Author

sent

@anandsiddharth
Copy link
Collaborator

Cool I will be checking on that over the weekend, will update here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants