Laravel Socialite "Facebook" The parameter app_id is required - laravel

So I am having the same problem as this user here : Laravel Socialite Facebook Login Error: The parameter app_id is required
and I have followed the solution give to this user. but I still get the same error.
even tried changing clinet_id to app_id.. nothing has changed the same error
The parameter app_id is required
'facebook' => [
'client_id' => 'hidden', //Facebook App Client ID
'client_secret' => 'hidden', // Your Facebook App Client Secret
'redirect' => 'http://localhost:8000/login/facebook/callback', // Your application route used to redirect users back to your app after authentication
],
route:
Route::get('login/facebook', 'Auth\LoginController#redirectToProvider');
Route::get('login/facebook/callback', 'Auth\LoginController#handleProviderCallback');
I cant see whats wrong here. added everything. from the documentation. in service the facade. what can be my mistake here? I feel its fairly obvious but I cant see it

you have to set app id, secret and call back url in config file so open config/services.php and .env file then set id and secret this way:
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('FACEBOOK_CALLBACK_URL'),
],
.env
FACEBOOK_CLIENT_ID=xxxxxxxxx
FACEBOOK_CLIENT_SECRET=xxxxxxx
FACEBOOK_CALLBACK_URL=http://localhost:8000/login/facebook/callback
After completion of .env edit please enter this command in your terminal for clear cache:php artisan config:cache

Related

How can I solve redirect error of Laravel Socialite?

I installed socialite to laravel project? But I have to change redirect url of google. Even though I changed url from google console and defined new client Id, client secret and url at config/services.php, I have problem when login with google that redirecting me to old url. What can be cause this error? We also clear the cache, but problem continues.. If you give me an idea, I will very appreciated.
return [
....
'google' => [
'client_id' => 'app id',
'client_secret' => 'add secret',
'redirect' => 'https://.../auth/google/callback',
],
]

How to login with laravel passport in seeder file?

On laravel backend API site with passport I use service for data crud operations
and inside of this service I use Auth::user() to fill creator of data.
Testing this service in POSTMAN I use oauth/token with client_id, client-secret, username, password
parameters and it works ok.
I need to add some init data in seeders using the same service
Looking how oauth/token at docs https://laravel.com/docs/9.x/passport
I added to my seeder:
use Illuminate\Support\Facades\Http;
...
$response = Http::asForm()->post(url('oauth/token'), [
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => 'username',
'password' => 'password',
'scope' => '',
]);
\Log::info($response->json()); // I can see valid response
if(Auth::user()) { // that condition did not true
\Log::info(Auth::user());
}
Which action have I to take to login with valid token?
When I refer Auth::user()->id in service I got error :
Attempt to read property "id" on null
I tried to debug by routes outpout:
.token › Laravel\Passport › AccessTokenController#issueToken
POST oauth/token/refresh ........................................................................................................................ passport.token
file src/Http/Controllers/AccessTokenController.php
but I see only token functionality...
"laravel/framework": "^9.2",
"laravel/passport": "^10.3",
Thanks in advance!
You can use Auth::loginUsingId() for user information that you want get

Laravel socialite dynamic redirectUrl not working in multi-tenant app

i have a multi-tenant app and i am trying to add Facebook linking in it i have tried the process using laravel socialite but i have a problem that when i use dynamic redirect url like so
return Socialite::driver('facebook')
->with([
'redirect_uri' => "https://" . $dynamichost . "/social/facebook/callback",
])
->redirect();
or this way
return Socialite::driver('facebook')->redirectUrl('https://' . $dynamichost .
'/social/facebook/callback')->redirect();
facebook returns error url mismatch. Note i also have set a value for redirect_url in .env
then i have services values like this
'facebook' => [
'client_id' => env('FACEBOOK_APP_ID'),
'client_secret' => env('FACEBOOK_APP_SECRET'),
'redirect' => env('CALLBACK_URL_FACEBOOK'),
'default_graph_ve`enter code here`rsion' => 'v3.3',
],
my guess is socialite somehow set the redirect url equal to the value which is coming from .env and when i change it dynamically it still thinks that url will be like the value of .env and i have tested this scenario the request get success response if keep the redirect url static.
Any suggestions how can i overcome this. thanks.
if you want to use custom redirect-uri dynamic :
use Socialite;
use Laravel\Socialite\Two\FacebookProvider;
$socialite = Socialite::buildProvider(
FacebookProvider::class, [
'client_id' => 'your_id',
'client_secret' => 'your_secret',
'redirect' => 'url',
'default_graph_version' => 'v3.3', //not sure if this needed as far as i know, in socialite the version is defined
]
)->redirect();
well it was dumb mistake i had to match the redirect url in callback handling method. its fixed now thanks.

Laravel passport 500 internal server error when using subdomain

Using laravel passport on my local machine and domain http://myapp.test, I have no problem.
When I push the code to my server on my main domain https://myapp.com, again no problem.
However, I have a sudomain used for my live test (pre-production) before to push to the main domain in production. If I use https://dev.myapp.com, then I get a 500 internal server error.
Any idea how to fix it?
This is the guzzle call I'm doing:
$http = new GuzzleHttp\Client;
$response = $http->post('https://dev.myapp.com/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 'client_id',
'client_secret' => 'client_secret_key',
'username' => 'john#example.com',
'password' => '123456',
'scope' => '',
],
]);
return $response;
If I change the url to my local or production website (changing the passport key and making sure the same user exists), it works properly.
My bad. Just forgot to run that command on the server for that specific domain as specified in the documentation. This command generates the encryption keys Passport needs in order to generate access token.
php artisan passport:keys

error parameter app_id is required

I installed Laravel5.5 Socialite 3.3, but can't make it work. It shows the error on the facebook page
parameter app_id is required.
You should try this:
Please check below code in config/service.php:
'facebook' => [
'client_id' => '222221956976734',
'client_secret' => 'a5acf8e8e01745d47rer829a0094vfvf',
'redirect' => 'http://localhost/myproject/public/callback',
],
Or more details please follow this link

Resources