vusal5555 Posted October 18 Share Posted October 18 Hi to everyone. I have been trying to implement social auth into application. I defined github and google auth credentials in my .env file. I access them in my services.php 'github' => [ 'client_id' => env('GITHUB_CLIENT_ID'), 'client_secret' => env('GITHUB_CLIENT_SECRET'), 'redirect' => '/auth/github/callback', ], 'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID'), 'client_secret' => env('GOOGLE_CLIENT_SECRET'), 'redirect' => '/auth/google/callback', ], Here is my controller as well <?php namespace App\Http\Controllers; use Laravel\Socialite\Facades\Socialite; class ProviderController extends Controller { public function redirect($provider) { return Socialite::driver($provider)->redirect(); } public function callback($provider) { $user = Socialite::driver($provider)->user(); dd($user); } } When I try to hit these two endpoints I receive the above error. Route::get('/auth/{provider}/redirect', [\App\Http\Controllers\ProviderController::class, 'redirect'])->name('github.redirect'); Route::get('/auth/{provider}/callback', [\App\Http\Controllers\ProviderController::class, 'callback']); I checked my enviroment variables and ran the tinker command and have access to them. I also cleared the cache. when I logged the error I got this message [2024-10-18 05:06:24] local.ERROR: Authentication error: {"provider":"github","message":"Client error: `GET https://api.github.com/user` resulted in a `401 Unauthorized` response: {\"message\":\"Bad credentials\",\"documentation_url\":\"https://docs.github.com/rest\",\"status\":\"401\"} "} Quote Link to comment https://forums.phpfreaks.com/topic/325046-getting-this-error-laravelsocialitetwoinvalidstateexception/ Share on other sites More sharing options...
requinix Posted October 18 Share Posted October 18 It pretty clearly says "bad credentials" in the error message... Quote Link to comment https://forums.phpfreaks.com/topic/325046-getting-this-error-laravelsocialitetwoinvalidstateexception/#findComment-1638175 Share on other sites More sharing options...
vusal5555 Posted October 19 Author Share Posted October 19 (edited) 23 hours ago, requinix said: It pretty clearly says "bad credentials" in the error message... What does it mean by bad credentials though? if it is credentials like client id and client secret, I have already defined them in my env file and checked by logging them in the tinker console. Edited October 19 by vusal5555 Quote Link to comment https://forums.phpfreaks.com/topic/325046-getting-this-error-laravelsocialitetwoinvalidstateexception/#findComment-1638276 Share on other sites More sharing options...
maxxd Posted October 19 Share Posted October 19 Do a dd() with the credentials to make sure you've actually got what you think. You may need to clear your caches (php artisan optimize:clear). And of course, verify that the credentials you're using are correct and valid. Quote Link to comment https://forums.phpfreaks.com/topic/325046-getting-this-error-laravelsocialitetwoinvalidstateexception/#findComment-1638291 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.